[ibsim patch 16/23] umad2sim.c: make_path should check the return value of mkdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 umad2sim/umad2sim.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/umad2sim/umad2sim.c b/umad2sim/umad2sim.c
index 84ab84fd81b6..80e7b8166638 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)
+			IBWARN("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, ...)
-- 
2.15.0-rc1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux