]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Simplify function
authorChristian Brauner <christianvanbrauner@gmail.com>
Sun, 25 Oct 2015 21:59:45 +0000 (22:59 +0100)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 6 Nov 2015 22:35:37 +0000 (17:35 -0500)
Instead of duplicating the cleanup-code, once for success and once for failure,
simply keep a variable fret which is -1 in the beginning and gets set to 0 on
success or stays -1 on failure.

Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/conf.c

index 3da3dffc14f8b418ce7dd98ef059b05f8b2ab0b8..c4eb42d1132865975e407f8d36be94100fea1d5c 100644 (file)
@@ -2190,6 +2190,7 @@ static int mount_entry_create_overlay_dirs(const struct mntent *mntent,
        char *upperdir = NULL;
        char *workdir = NULL;
        char **opts = NULL;
+       int fret = -1;
        int ret = 0;
        size_t arrlen = 0;
        size_t dirlen = 0;
@@ -2237,14 +2238,12 @@ static int mount_entry_create_overlay_dirs(const struct mntent *mntent,
                                WARN("Failed to create workdir");
                        }
 
-       free(rootfsdir);
-       lxc_free_array((void **)opts, free);
-       return 0;
+       fret = 0;
 
 err:
        free(rootfsdir);
        lxc_free_array((void **)opts, free);
-       return -1;
+       return fret;
 }
 
 static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
@@ -2258,6 +2257,7 @@ static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
        char *tmp = NULL;
        char *upperdir = NULL;
        char **opts = NULL;
+       int fret = -1;
        int ret = 0;
        size_t arrlen = 0;
        size_t i;
@@ -2299,14 +2299,12 @@ static int mount_entry_create_aufs_dirs(const struct mntent *mntent,
                        WARN("Failed to create upperdir");
                }
 
-       free(rootfsdir);
-       lxc_free_array((void **)opts, free);
-       return 0;
+       fret = 0;
 
 err:
        free(rootfsdir);
        lxc_free_array((void **)opts, free);
-       return -1;
+       return fret;
 }