[FIX] prevent issue 48/29748/1
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 3 Nov 2014 18:06:22 +0000 (21:06 +0300)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Mon, 3 Nov 2014 18:06:22 +0000 (21:06 +0300)
|-------------------------|------------------------|
| Type                    | Function               |
|-------------------------|------------------------|
| dead code               |get_device_network_type |
|-------------------------|------------------------|

Change-Id: Ifadbf78d32f2535cd7d477f9278cd9ed51fbcdb4
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
daemon/sys_stat.c

index 57afccb..54484e7 100644 (file)
@@ -1221,7 +1221,12 @@ exit:
 #define print_to_buf(buf, buflen, str)                         \
 do {                                                           \
        if (strlen(str) <= buflen) {                            \
-               lenin = snprintf(buf, buflen, "CDMA,");         \
+               lenin = snprintf(buf + len, buflen, "CDMA,");   \
+               if (lenin <= 0) {                               \
+                       LOGE("can not pack <%s>\n", str);       \
+                       goto exit;                              \
+               }                                               \
+               lenin -= 1;                                     \
                len += lenin;                                   \
                buflen -= lenin;                                \
        } else {                                                \
@@ -1234,6 +1239,7 @@ static int get_device_network_type(char* buf, size_t buflen)
 {
        int len = 0, lenin = 0;
 
+       buf[0] = '\0';
 
        if (is_cdma_available())
                print_to_buf(buf, buflen, "CDMA,");
@@ -1262,9 +1268,6 @@ static int get_device_network_type(char* buf, size_t buflen)
        if (is_lte_available())
                print_to_buf(buf, buflen, "LTE,");
 
-       if (len != 0)
-               buf[--len] = 0;
-
 exit:
        return len;
 }