pass: parser: Change pass_res_type in pass.conf from number to string 97/134897/2 submit/tizen/20170629.044637
authorWook Song <wook16.song@samsung.com>
Tue, 20 Jun 2017 08:10:07 +0000 (17:10 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 21 Jun 2017 01:19:59 +0000 (01:19 +0000)
This patch changes the type of the value of "pass_res_type" in each
PassResource section of the pass.conf file from a number to a meaningful
string like cpu, bus, and gpu.

Change-Id: I1d3a33d7a16b93f44b422ca470cd60c70198e3fc
Signed-off-by: Wook Song <wook16.song@samsung.com>
src/pass/pass-parser.c

index 0051d94..43e4946 100644 (file)
@@ -17,6 +17,7 @@
  */
 
 
+#include <ctype.h>
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -469,6 +470,7 @@ void pass_put_table(struct pass_policy *policy)
 static int  pass_parse_resource_data(struct parse_result *result,
                                    void *user_data, int id)
 {
+       char buf[BUFF_MAX];
        struct pass *pass = user_data;
        struct pass_conf_data *conf_data = &(pass->res[id].cdata);
 
@@ -476,7 +478,20 @@ static int  pass_parse_resource_data(struct parse_result *result,
                return 0;
 
        if (MATCH(result->name, "pass_res_type")) {
-               conf_data->res_type = atoi(result->value);
+               int i;
+
+               memset(buf, 0, BUFF_MAX);
+               for (i = 0; i < strlen(result->value); i++)
+                       buf[i] = tolower(result->value[i]);
+
+               if (!strncmp(buf, PASS_RESOURCE_CPU_NAME, strlen(buf)))
+                       conf_data->res_type = PASS_RESOURCE_CPU_ID;
+               else if (!strncmp(buf, PASS_RESOURCE_GPU_NAME, strlen(buf)))
+                       conf_data->res_type = PASS_RESOURCE_GPU_ID;
+               else if (!strncmp(buf, PASS_RESOURCE_BUS_NAME, strlen(buf)))
+                       conf_data->res_type = PASS_RESOURCE_BUS_ID;
+               else
+                       return -EINVAL;
        } else if (MATCH(result->name, "pass_res_name")) {
                int len = strlen(result->value);
                snprintf(conf_data->res_name, len + 1, "%s", result->value);