]> sourceware.org Git - lvm2.git/commitdiff
config_file: remove unused code 1358190087
authorDavid Teigland <teigland@redhat.com>
Tue, 2 Jul 2024 21:24:12 +0000 (16:24 -0500)
committerDavid Teigland <teigland@redhat.com>
Tue, 2 Jul 2024 21:24:12 +0000 (16:24 -0500)
config_file_read() is only used for regular files, not devices.

lib/config/config.c
lib/config/config.h
lib/format_text/import.c

index df287ef960d29e8e3e445a41ec249d039b9b6086..7ec25708cd1fd20a7444662a9472e611f227c618 100644 (file)
@@ -265,7 +265,7 @@ struct dm_config_tree *config_file_open_and_read(const char *config_file,
        }
 
        log_very_verbose("Loading config file: %s", config_file);
-       if (!config_file_read(cft)) {
+       if (!config_file_read_from_file(cft)) {
                log_error("Failed to load config file %s", config_file);
                goto bad;
        }
@@ -589,7 +589,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
        return r;
 }
 
-int config_file_read(struct dm_config_tree *cft)
+int config_file_read_from_file(struct dm_config_tree *cft)
 {
        const char *filename = NULL;
        struct config_source *cs = dm_config_get_custom(cft);
@@ -597,7 +597,6 @@ int config_file_read(struct dm_config_tree *cft)
        struct stat info;
        struct device fake_dev = { 0 };
        struct dm_str_list *alias;
-       int free_fake = 0;
        int fd;
        int r;
 
@@ -610,42 +609,38 @@ int config_file_read(struct dm_config_tree *cft)
 
        cf = cs->source.file;
 
+       if (cf->dev)
+               return_0;
+
        /* fixme: get rid of fake dev and just
           add separate code paths for files */
 
-       if (!cf->dev) {
-               if (!(alias = zalloc(sizeof(*alias))))
-                       return_0;
-               if (!(alias->str = strdup(filename))) {
-                       free(alias);
-                       return_0;
-               }
-               dev_init(&fake_dev);
-               fake_dev.flags = DEV_REGULAR;
-               dm_list_add(&fake_dev.aliases, &alias->list);
-
-               if ((fd = open(filename, O_RDONLY, 0777)) < 0) {
-                       log_error("Failed to open config file %s.", filename);
-                       free((void*)alias->str);
-                       free((void*)alias);
-                       return_0;
-               }
-               fake_dev.fd = fd;
-               free_fake = 1;
-               cf->dev = &fake_dev;
+       if (!(alias = zalloc(sizeof(*alias))))
+               return_0;
+       if (!(alias->str = strdup(filename))) {
+               free(alias);
+               return_0;
        }
+       dev_init(&fake_dev);
+       fake_dev.flags = DEV_REGULAR;
+       dm_list_add(&fake_dev.aliases, &alias->list);
 
-       r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0,
-                               (checksum_fn_t) NULL, 0, 0, 0);
-
-       if (free_fake) {
+       if ((fd = open(filename, O_RDONLY, 0777)) < 0) {
+               log_error("Failed to open config file %s.", filename);
                free((void*)alias->str);
                free((void*)alias);
-               close(fd);
-       } else {
-               if (!dev_close(cf->dev))
-                       stack;
+               return_0;
        }
+       fake_dev.fd = fd;
+       cf->dev = &fake_dev;
+
+       r = config_file_read_fd(cft, cf->dev, DEV_IO_MDA_CONTENT, 0, (size_t) info.st_size, 0, 0,
+                               (checksum_fn_t) NULL, 0, 0, 0);
+
+       free((void*)alias->str);
+       free((void*)alias);
+       close(fd);
+
        cf->dev = NULL;
 
        return r;
index 3926b12f5df1eb76bbfa4d327c24c1d541c4e3c8..5ca877222f5565d7665672ff002bedbf64c6c675 100644 (file)
@@ -244,7 +244,7 @@ int config_file_read_fd(struct dm_config_tree *cft, struct device *dev, dev_io_r
                        off_t offset, size_t size, off_t offset2, size_t size2,
                        checksum_fn_t checksum_fn, uint32_t checksum,
                        int skip_parse, int no_dup_node_check);
-int config_file_read(struct dm_config_tree *cft);
+int config_file_read_from_file(struct dm_config_tree *cft);
 struct dm_config_tree *config_file_open_and_read(const char *config_file, config_source_t source,
                                                 struct cmd_context *cmd);
 int config_write(struct dm_config_tree *cft, struct config_def_tree_spec *tree_spec,
index 5f74ae4204c679cf8db75d157a56b6a196dae635..fa0a6c2fd2b78b7314b7aa108d788f7c519d6a05 100644 (file)
@@ -67,7 +67,7 @@ int text_read_metadata_summary(const struct format_type *fmt,
                        goto out;
                }
        } else {
-               if (!config_file_read(cft)) {
+               if (!config_file_read_from_file(cft)) {
                        log_warn("WARNING: invalid metadata text from file.");
                        goto out;
                }
@@ -161,7 +161,7 @@ struct volume_group *text_read_metadata(struct format_instance *fid,
                        goto out;
                }
        } else {
-               if (!config_file_read(cft)) {
+               if (!config_file_read_from_file(cft)) {
                        log_warn("WARNING: couldn't read volume group metadata from file.");
                        goto out;
                }
This page took 0.042488 seconds and 5 git commands to generate.