Code bugs're fixed. 11/14911/1
authorsh.pi <sh.pi@samsung.com>
Fri, 3 May 2013 10:23:35 +0000 (19:23 +0900)
committerKrzysztof Sasiak <k.sasiak@samsung.com>
Mon, 13 Jan 2014 15:16:01 +0000 (16:16 +0100)
src/display/core.c 1778:  Declaring variable "i" without initializer.
src/display/core.c  771:  string_null_argument: Function "read(int, void *, size_t)" does not terminate string "*pname"
src/display/core.c  287:  missing_return: Arriving at the end of a function without returning a value.
src/display/poll.c  235:  leaked_storage: Variable "new_dev" going out of scope leaks the storage it points to.

Change-Id: I3eb4d79cdbc1c367bc776a934e3d217ccd70f37d
Signed-off-by: Krzysztof Sasiak <k.sasiak@samsung.com>
src/display/core.c

index 6850685..5eaf6b7 100644 (file)
@@ -291,7 +291,10 @@ static int proc_condition(PMMsg *data)
                snprintf(pname, PATH_MAX,
                        "does not exist now(may be dead without unlock)");
        } else {
-               read(fd_cmdline, pname, PATH_MAX);
+               int r;
+               r = read(fd_cmdline, pname, PATH_MAX);
+               if ((r >= 0) && (r < PATH_MAX))
+                       pname[r] = '\0';
                close(fd_cmdline);
        }
 
@@ -632,7 +635,10 @@ void print_info(int fd)
                                        "does not exist now"
                                        "(may be dead without unlock)");
                        } else {
-                               read(fd_cmdline, pname, PATH_MAX);
+                               int r;
+                               r = read(fd_cmdline, pname, PATH_MAX);
+                               if ((r >= 0) && (r < PATH_MAX))
+                                       pname[r] = '\0';
                                close(fd_cmdline);
                        }
                        snprintf(buf, sizeof(buf),
@@ -1573,7 +1579,7 @@ static void display_init(void *data)
 
 static void display_exit(void *data)
 {
-       int i;
+       int i = INIT_END;
 
        status = DEVICE_OPS_STATUS_STOP;
        end_battinfo_gathering();