Message ID | 625c55227b1f4e03320940cb087e466f019ca67e.1608315719.git.aclaudi@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Delegated to: | David Ahern |
Headers | show |
Series | Some fixes to lib/fs.c | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
Hi Andrea, On Fri, Dec 18, 2020 at 08:09:22PM +0100, Andrea Claudi wrote: > 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. To me it rather seems like I rebased the original commit into a mess. Or I got really confused by the covscan error message this is based upon. Either way, I don't see why this would not be a bug. :) > This seems unnecessary, as we can use the return code from the first > call and check for errno if not 0. > Fixes: ac3415f5c1b1d ("lib/fs: Fix and simplify make_path()") > Signed-off-by: Andrea Claudi <aclaudi@redhat.com> Acked-by: Phil Sutter <phil@nwl.cc> Thanks, Phil
diff --git a/lib/fs.c b/lib/fs.c index 4b90a704..2ae506ec 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -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;
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. Signed-off-by: Andrea Claudi <aclaudi@redhat.com> --- lib/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)