pass: Fix bug in initializing pass_table
authorWook Song <wook16.song@samsung.com>
Tue, 20 Dec 2016 06:52:57 +0000 (15:52 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Mon, 16 Jan 2017 11:35:37 +0000 (20:35 +0900)
This patch fixes following issue:

I/PASS    (28120): pass-core.c: pass_governor_core_timer(453) > Change
the period of governor timer from 0.400000s to
28684447001453215729166007156692003357432084613448073247205944301959706
06648226909257285691507618049531741760802643920937127227407207970809900
37736192679308348770424336630500142586913989268043480145518076661186128
31491039131628038411330434453835782245089155343230483828779371137532403
45772032.000000s

TODO: This is a temporary patch, which uses a dangerous way to
initialize the dynamically allocated structure array, pass_table.

Signed-off-by: Wook Song <wook16.song@samsung.com>
src/pass/pass-plugin.c

index fa88a775db1ea584baa0935fbdbded781b08754e..1205463412707b2086a9356ee73fe4a3f38d195f 100644 (file)
@@ -449,6 +449,17 @@ static int pass_parse_core(struct parse_result *result, void *user_data)
                        _E("cannot allocate memory for pass_table\n");
                        return -EINVAL;
                }
+               /*
+                * TODO: This is a dangerous way to initialize C-style struct type
+                * pointer variables. When we refactor source code of PASS, it is
+                * required to better use consturctor functions.
+                */
+
+               if (!memset(policy->pass_table, 0,
+                                       sizeof(struct pass_table) * policy->num_levels)){
+                       _E("cannot initialize pass_table\n");
+                       return -EINVAL;
+               }
        }
 
        return 0;
@@ -547,32 +558,6 @@ int get_pass_table(struct pass_policy *policy, char *pass_conf_path)
        policy->gov_timeout = 0;
        policy->last_time = 0;
 
-       for (level = 0; level < policy->num_levels; level++) {
-               policy->pass_table[level].limit_max_freq = 0;
-               policy->pass_table[level].limit_max_cpu = 0;
-               policy->pass_table[level].gov_timeout = 0;
-
-               policy->pass_table[level].num_down_cond = 0;
-               policy->pass_table[level].down_cond[0].freq = 0;
-               policy->pass_table[level].down_cond[0].nr_running = 0;
-               policy->pass_table[level].down_cond[0].busy_cpu = 0;
-
-               policy->pass_table[level].num_up_cond = 0;
-               policy->pass_table[level].up_cond[0].freq = 0;
-               policy->pass_table[level].up_cond[0].nr_running = 0;
-               policy->pass_table[level].up_cond[0].busy_cpu = 0;
-
-               policy->pass_table[level].num_left_cond = 0;
-               policy->pass_table[level].left_cond[0].freq = 0;
-               policy->pass_table[level].left_cond[0].nr_running = 0;
-               policy->pass_table[level].left_cond[0].busy_cpu = 0;
-
-               policy->pass_table[level].num_right_cond = 0;
-               policy->pass_table[level].right_cond[0].freq = 0;
-               policy->pass_table[level].right_cond[0].nr_running = 0;
-               policy->pass_table[level].right_cond[0].busy_cpu = 0;
-       }
-
        ret = config_parse(pass_conf_path, pass_load_config, policy);
        if (ret < 0) {
                _E("cannot parse %s\n", pass_conf_path);