lib/fs: avoid double call to mkdir on make_path()

make_path() function calls mkdir two times in a row. The first one it
stores mkdir return code, and then it calls it again to check for errno.

This seems unnecessary, as we can use the return code from the first
call and check for errno if not 0.

Fixes: ac3415f5c1 ("lib/fs: Fix and simplify make_path()")
Acked-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Andrea Claudi 2021-02-22 19:14:31 +01:00 committed by Stephen Hemminger
parent d4fcdbbec9
commit 1de363b180
1 changed files with 1 additions and 1 deletions

View File

@ -253,7 +253,7 @@ int make_path(const char *path, mode_t mode)
*delim = '\0';
rc = mkdir(dir, mode);
if (mkdir(dir, mode) != 0 && errno != EEXIST) {
if (rc && errno != EEXIST) {
fprintf(stderr, "mkdir failed for %s: %s\n",
dir, strerror(errno));
goto out;