]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: cleanup macros lxc_mount_auto_mounts
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:43:04 +0000 (23:43 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 19 Feb 2019 22:43:04 +0000 (23:43 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index d7ae64cefb862ceb89afb1e02f65f93031005b30..7bea4646818fae56cee914033e6b15757d18a168 100644 (file)
@@ -689,10 +689,9 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
        };
 
        for (i = 0; default_mounts[i].match_mask; i++) {
+               __do_free char *destination = NULL, *source = NULL;
                int saved_errno;
                unsigned long mflags;
-               char *destination = NULL;
-               char *source = NULL;
                if ((flags & default_mounts[i].match_mask) != default_mounts[i].match_flag)
                        continue;
 
@@ -705,16 +704,12 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
 
                if (!default_mounts[i].destination) {
                        ERROR("BUG: auto mounts destination %d was NULL", i);
-                       free(source);
                        return -1;
                }
 
                /* will act like strdup if %r is not present */
                destination = lxc_string_replace("%r", conf->rootfs.path ? conf->rootfs.mount : "", default_mounts[i].destination);
                if (!destination) {
-                       saved_errno = errno;
-                       free(source);
-                       errno = saved_errno;
                        return -1;
                }
 
@@ -732,8 +727,6 @@ static int lxc_mount_auto_mounts(struct lxc_conf *conf, int flags, struct lxc_ha
                        SYSERROR("Failed to mount \"%s\" on \"%s\" with flags %lu", source, destination, mflags);
                }
 
-               free(source);
-               free(destination);
                if (r < 0) {
                        errno = saved_errno;
                        return -1;