Coverity fixes. 18/155318/1 accepted/tizen/unified/20171019.060906 submit/tizen/20171018.075023
authorINSUN PYO <insun.pyo@samsung.com>
Fri, 13 Oct 2017 02:15:25 +0000 (02:15 +0000)
committerINSUN PYO <insun.pyo@samsung.com>
Fri, 13 Oct 2017 02:16:11 +0000 (02:16 +0000)
Signed-off-by: INSUN PYO <insun.pyo@samsung.com>
Change-Id: I9201254a8076891148aadb9a6932bebaef4263a4

src/haptic/standard-vibcore.c

index 510b717..4e40c22 100644 (file)
@@ -71,15 +71,14 @@ static int vibration_load_config(struct parse_result *result, void *user_data)
        }
 
        conf->pattern = strdup(result->name);
-       if (!conf->pattern)
+       if (!conf->pattern) {
                _E("fail to copy %s pattern data", result->name);
+               free(conf);
+               return -ENOMEM;
+       }
 
        value = result->value;
-
-       if (!value)
-               len = 0;
-       else
-               len = strlen(value);
+       len = strlen(value);
 
        if (len == 0) {
                data = (struct duration_data *)malloc(sizeof(struct duration_data));
@@ -97,6 +96,7 @@ static int vibration_load_config(struct parse_result *result, void *user_data)
                return 0;
        }
 
+       /* value : 100D or 100D0W or 250D250W250D750W*/
        do {
                data = (struct duration_data *)malloc(sizeof(struct duration_data));
                if (!data) {
@@ -112,26 +112,22 @@ static int vibration_load_config(struct parse_result *result, void *user_data)
                if (check) {
                        *check = '\0';
                        data->duration = strtol(value, NULL, 10);
-                       if (!value)
-                               len = len - 1;
-                       else
-                               len = len - strlen(value) - 1;
+                       len = len - strlen(value) - 1;
                        value = check + 1;
                }
+
                check = strchr(value, 'W');
                if (check) {
                        *check = '\0';
                        data->wait = strtol(value, NULL, 10);
-                       if (!value)
-                               len = len - 1;
-                       else
-                               len = len - strlen(value) - 1;
+                       len = len - strlen(value) - 1;
                        value = check + 1;
                }
+
                DD_LIST_APPEND(conf->data, data);
                if (data->duration == 0 && data->wait == 0)
                        break;
-       } while (value && len > 0);
+       } while (len > 0);
 
        DD_LIST_APPEND(vib_conf_list, conf);