pass: parser: Replace with bool data type to prevent mismatched type casting 51/277351/1
authorChanwoo Choi <cw00.choi@samsung.com>
Tue, 5 Jul 2022 10:11:15 +0000 (19:11 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Tue, 5 Jul 2022 10:17:10 +0000 (19:17 +0900)
Until now, even if use DATA_TYPE_BOOLEN, use 'int' variable type.
It might cause the unknown issue by mismatched type casting
on get_property() fucntion. In order to prevent the wrong type casting,
replace with bool data type instead of integer type.

Change-Id: I51791d72579afc97b73b6a67d9a9711c21c033f4
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
src/pass/pass-parser.c
src/pmqos/pmqos-parser.c
src/thermal/thermal-parser.c

index 5a9001a..d268050 100644 (file)
@@ -108,7 +108,7 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
                                struct pass_scenario *scenario)
 {
        char name[BUFF_MAX] = {};
-       int support;
+       bool support;
        int target_level;
        int cpuhp_min_level;
        int cpuhp_max_level;
@@ -117,7 +117,7 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        int temp_end;
        int threshold;
        int timer_interval_ms;
-       int overridable;
+       bool overridable;
        int ret = 0;
 
        /* Get property values */
@@ -174,7 +174,7 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
 
        /* Initialize config_data from property values of confiugartion file */
        snprintf(scenario->name, NAME_MAX, "%s", name);
-       scenario->state = (support < 0) ? 1 : support;
+       scenario->state = support;
        scenario->level = target_level;
 
        /* - property for only pmqos module */
@@ -186,7 +186,7 @@ static int parse_scenario(struct pass_resource *res, json_object *obj,
        scenario->thermal.temp_end = temp_end;
        scenario->thermal.threshold = threshold;
        scenario->thermal.timer_interval = timer_interval_ms;
-       scenario->thermal.overridable = (overridable < 0) ? 1 : overridable;
+       scenario->thermal.overridable = overridable;
 
        return 0;
 }
@@ -685,7 +685,7 @@ static int parse_cpuhp(struct pass_resource *res, json_object *obj)
  */
 static int parse_header(struct pass_resource *res, json_object *obj)
 {
-       int support;
+       bool support;
        int init_level;
        json_object *level_list = NULL;
        int num_levels = 0, ret = 0, i;
index 7cc5a80..845f441 100644 (file)
@@ -53,7 +53,7 @@ static int pmqos_parse_scenario(json_object *obj, struct scenario *scenario)
 {
        char name[BUFF_MAX] = {};
        int max_duration_ms;
-       int support;
+       bool support;
        int ret = 0;
 
        /* Get property values */
@@ -73,7 +73,7 @@ static int pmqos_parse_scenario(json_object *obj, struct scenario *scenario)
        /* Initialize config_data from property values of confiugartion file */
        snprintf(scenario->name, strlen(name) + 1, "%s", name);
        scenario->max_duration_ms = (max_duration_ms < 0) ? 0 : max_duration_ms;
-       scenario->support = (support < 0) ? 1 : support;
+       scenario->support = support;
 
        return 0;
 }
@@ -88,7 +88,7 @@ static int pmqos_parse_scenario(json_object *obj, struct scenario *scenario)
  */
 static int pmqos_load_config(json_object *obj, struct pmqos_scenario *scenarios)
 {
-       int pmqos_support;
+       bool pmqos_support;
        json_object *pmqos_scenario_list = NULL;
        int num_scenarios = 0, ret, i;
 
@@ -106,7 +106,7 @@ static int pmqos_load_config(json_object *obj, struct pmqos_scenario *scenarios)
        }
 
        /* Check the validation of property value */
-       if (pmqos_support <= 0 || num_scenarios <= 0) {
+       if (!pmqos_support || num_scenarios <= 0) {
                _I("Disable PMQOS module\n");
                return 0;
        }
index c1660b4..09edc5b 100644 (file)
@@ -50,7 +50,7 @@
 static int thermal_parse_scenario(json_object *obj, struct scenario *scenario)
 {
        char name[BUFF_MAX] = {};
-       int support;
+       bool support;
        int ret = 0;
 
        /* Get property values */
@@ -67,7 +67,7 @@ static int thermal_parse_scenario(json_object *obj, struct scenario *scenario)
 
        /* Initialize config_data from property values of confiugartion file */
        snprintf(scenario->name, strlen(name) + 1, "%s", name);
-       scenario->support = (support < 0) ? 1 : support;
+       scenario->support = support;
 
        return 0;
 }
@@ -81,7 +81,7 @@ static int thermal_parse_scenario(json_object *obj, struct scenario *scenario)
  */
 static int thermal_load_config(json_object *obj, struct thermal_scenario *scenarios)
 {
-       int thermal_support;
+       bool thermal_support;
        json_object *thermal_scenario_list = NULL;
        int num_scenarios = 0, ret = 0, i;
 
@@ -99,7 +99,7 @@ static int thermal_load_config(json_object *obj, struct thermal_scenario *scenar
        }
 
        /* Check the validation of property value */
-       if (thermal_support <= 0 || num_scenarios <= 0) {
+       if (!thermal_support || num_scenarios <= 0) {
                _I("Disable thermal module\n");
                return 0;
        }