]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: fix mount_entry_create_dir_file
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Fri, 4 Sep 2015 18:15:13 +0000 (13:15 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 15 Sep 2015 22:52:35 +0000 (18:52 -0400)
First, fix use of uninitialized variable 'ret'.  Then, actually use
the value it returned in its caller.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/conf.c

index bd11d507f712f278e14a78fa8d2e83d61da2b2b0..c6fbbc8edc7416528264bc9d95d84bdaab92df7c 100644 (file)
@@ -2139,7 +2139,7 @@ static int mount_entry_create_dir_file(const struct mntent *mntent,
                                       const char* path)
 {
        char *pathdirname = NULL;
-       int ret;
+       int ret = 0;
        FILE *pathfile = NULL;
 
        if (hasmntopt(mntent, "create=dir")) {
@@ -2177,6 +2177,12 @@ static inline int mount_entry_on_generic(struct mntent *mntent,
 
        ret = mount_entry_create_dir_file(mntent, path);
 
+       if (ret < 0)
+               return optional ? 0 : -1;
+
+       if (ret < 0 && !optional)
+               return -1;
+
        cull_mntent_opt(mntent);
 
        if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) {