From: Serge Hallyn Date: Fri, 4 Sep 2015 18:15:13 +0000 (-0500) Subject: coverity: fix mount_entry_create_dir_file X-Git-Tag: lxc-1.0.8~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9419eabe41b7615091d7c4d90a21f7e5a90db50;p=thirdparty%2Flxc.git coverity: fix mount_entry_create_dir_file First, fix use of uninitialized variable 'ret'. Then, actually use the value it returned in its caller. Signed-off-by: Serge Hallyn --- diff --git a/src/lxc/conf.c b/src/lxc/conf.c index bd11d507f..c6fbbc8ed 100644 --- a/src/lxc/conf.c +++ b/src/lxc/conf.c @@ -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) {