diff options
author | Stefan Metzmacher <metze@samba.org> | 2012-03-14 10:43:54 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2012-03-14 12:00:46 +0100 |
commit | f30626111994c0a5a4b886f52de1f62bfc52de3c (patch) | |
tree | 760c47897b6e6456df6b1a1225b1457011ed7103 | |
parent | bd492befc0cbaa3d1ba3438a62d6e4832b98ee54 (diff) | |
download | samba-f30626111994c0a5a4b886f52de1f62bfc52de3c.tar.gz samba-f30626111994c0a5a4b886f52de1f62bfc52de3c.tar.bz2 samba-f30626111994c0a5a4b886f52de1f62bfc52de3c.zip |
lib/util: do an early return on error directory_create_or_exist()
metze
-rw-r--r-- | lib/util/util.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index 1a5c9a196b..54237c57d8 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -150,22 +150,22 @@ _PUBLIC_ bool directory_create_or_exist(const char *dname, uid_t uid, old_umask = umask(0); if (lstat(dname, &st) == -1) { - if (errno == ENOENT) { - /* Create directory */ - if (mkdir(dname, dir_perms) == -1) { - DEBUG(0, ("mkdir failed on directory " - "%s: %s\n", dname, - strerror(errno))); - umask(old_umask); - return false; - } - } else { + if (errno != ENOENT) { DEBUG(0, ("lstat failed on directory %s: %s\n", dname, strerror(errno))); umask(old_umask); return false; } + /* Create directory */ + if (mkdir(dname, dir_perms) == -1) { + DEBUG(0, ("mkdir failed on directory " + "%s: %s\n", dname, + strerror(errno))); + umask(old_umask); + return false; + } + return true; } |