Message ID | 20190109062907.18321-1-honli@redhat.com (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | [ibsim,v2] umad2sim.c: make_path should check the return value of mkdir | expand |
On 1/9/2019 1:29 AM, Honggang Li wrote: > Issue was detected by Coverity. > --------------------------- > ibsim-0.7/umad2sim/umad2sim.c:151: check_return: Calling "mkdir(dir, 493U)" without checking return value. This library function may fail and return an error code. > --------------------------- > > Also covert the function into a void function, as none of callers > checked the return value of make_path. > > Signed-off-by: Honggang Li <honli@redhat.com> Thanks. Applied. -- Hal
diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c index b5a0532d0c72..46510b011cca 100644 --- a/umad2sim/umad2sim.c +++ b/umad2sim/umad2sim.c @@ -137,7 +137,7 @@ static void convert_sysfs_path(char *new_path, unsigned size, snprintf(new_path, size, "%s/%s", umad2sim_sysfs_prefix, old_path); } -static int make_path(char *path) +static void make_path(char *path) { char dir[1024]; char *p; @@ -148,14 +148,13 @@ static int make_path(char *path) p = strchr(p, '/'); if (p) *p = '\0'; - mkdir(dir, 0755); + if (mkdir(dir, 0755) && errno != EEXIST) + IBPANIC("Failed to make directory <%s>", dir); if (p) { *p = '/'; p++; } } while (p && p[0]); - - return 0; } static int file_printf(char *path, char *name, const char *fmt, ...)
Issue was detected by Coverity. --------------------------- ibsim-0.7/umad2sim/umad2sim.c:151: check_return: Calling "mkdir(dir, 493U)" without checking return value. This library function may fail and return an error code. --------------------------- Also covert the function into a void function, as none of callers checked the return value of make_path. Signed-off-by: Honggang Li <honli@redhat.com> --- umad2sim/umad2sim.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)