]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: cleanup set_config_rootfs_path()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 15:10:13 +0000 (16:10 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 15:49:40 +0000 (16:49 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/confile.c

index d53efa07ba58dab9cc9759d56c8bd0add20e288b..c2a9fe7559f1f2005dfc161f9de645a67ba15afd 100644 (file)
@@ -2540,8 +2540,9 @@ static int set_config_includefiles(const char *key, const char *value,
 static int set_config_rootfs_path(const char *key, const char *value,
                                  struct lxc_conf *lxc_conf, void *data)
 {
+       __do_free char *dup = NULL;
        int ret;
-       char *dup, *tmp;
+       char *tmp;
        const char *container_path;
 
        if (lxc_config_value_empty(value)) {
@@ -2552,7 +2553,7 @@ static int set_config_rootfs_path(const char *key, const char *value,
 
        dup = strdup(value);
        if (!dup)
-               return -1;
+               return ret_errno(ENOMEM);
 
        /* Split <storage type>:<container path> into <storage type> and
         * <container path>. Set "rootfs.bdev_type" to <storage type> and
@@ -2563,10 +2564,8 @@ static int set_config_rootfs_path(const char *key, const char *value,
                *tmp = '\0';
 
                ret = set_config_path_item(&lxc_conf->rootfs.bdev_type, dup);
-               if (ret < 0) {
-                       free(dup);
-                       return -1;
-               }
+               if (ret < 0)
+                       return ret_errno(ENOMEM);
 
                tmp++;
                container_path = tmp;
@@ -2574,10 +2573,7 @@ static int set_config_rootfs_path(const char *key, const char *value,
                container_path = value;
        }
 
-       ret = set_config_path_item(&lxc_conf->rootfs.path, container_path);
-       free(dup);
-
-       return ret;
+       return set_config_path_item(&lxc_conf->rootfs.path, container_path);
 }
 
 static int set_config_rootfs_managed(const char *key, const char *value,