]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
confile: cleanup set_config_rootfs_options()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 8 Dec 2020 15:12:35 +0000 (16:12 +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 c2a9fe7559f1f2005dfc161f9de645a67ba15afd..4fdc96c5a9cdf2b9e425e2a2adcc4a71f689353a 100644 (file)
@@ -2591,30 +2591,26 @@ static int set_config_rootfs_mount(const char *key, const char *value,
 static int set_config_rootfs_options(const char *key, const char *value,
                                     struct lxc_conf *lxc_conf, void *data)
 {
+       __do_free char *mdata = NULL, *opts = NULL;
        unsigned long mflags = 0, pflags = 0;
-       char *mdata = NULL, *opts = NULL;
-       int ret;
        struct lxc_rootfs *rootfs = &lxc_conf->rootfs;
+       int ret;
 
        ret = parse_mntopts(value, &mflags, &mdata);
        if (ret < 0)
-               return -EINVAL;
+               return ret_errno(EINVAL);
 
        ret = parse_propagationopts(value, &pflags);
-       if (ret < 0) {
-               free(mdata);
-               return -EINVAL;
-       }
+       if (ret < 0)
+               return ret_errno(EINVAL);
 
        ret = set_config_string_item(&opts, value);
-       if (ret < 0) {
-               free(mdata);
-               return -ENOMEM;
-       }
+       if (ret < 0)
+               return ret_errno(ENOMEM);
 
        rootfs->mountflags = mflags | pflags;
-       rootfs->options = opts;
-       rootfs->data = mdata;
+       rootfs->options = move_ptr(opts);
+       rootfs->data = move_ptr(mdata);
 
        return 0;
 }