From 95be6f849de80507b54239ba5e3eee491d6d4b02 Mon Sep 17 00:00:00 2001 From: Willy Liu Date: Tue, 30 May 2023 09:45:21 +0000 Subject: [PATCH] [Edgecore][as9516-32d] Parsing from the first value of curl response data for curl parser Parsing from the first value of curl response data for curl parser Signed-off-by: Willy Liu --- .../x86_64_accton_as9516_32d/module/src/fani.c | 10 +++------- .../x86_64_accton_as9516_32d/module/src/psui.c | 14 +++++--------- .../x86_64_accton_as9516_32d/module/src/thermali.c | 9 +++------ 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/fani.c b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/fani.c index 903f8a8e3..f01c69ba8 100644 --- a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/fani.c +++ b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/fani.c @@ -155,8 +155,8 @@ static void ps_call_back(void *p) AIM_LOG_ERROR("Failed CURL response data.\n"); return; } - - i = data_loc_start - ptr; + /* Start to parse from the first value, ignore '[' */ + i = data_loc_start - ptr + 1; while (ptr[i] && ptr[i] != ']') { j = 0; @@ -180,11 +180,7 @@ static void ps_call_back(void *p) /* There are three string - model name/serial/model ver */ if ((k < curl_data_loc_psu_model_name) || (k > curl_data_loc_psu_model_ver)) { - /* To avoid to get error char in first item */ - if (k == 0) - ps[k] = atoi(str+1); - else - ps[k] = atoi(str); + ps[k] = atoi(str); } k++; diff --git a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/psui.c b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/psui.c index 79cac34b1..a9c13995d 100644 --- a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/psui.c +++ b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/psui.c @@ -102,8 +102,8 @@ static void ps_call_back(void *p) AIM_LOG_ERROR("Failed CURL response data.\n"); return; } - - i = data_loc_start - ptr; + /* Start to parse from the first value, ignore '[' */ + i = data_loc_start - ptr + 1; while (ptr[i] && ptr[i] != ']') { j = 0; @@ -125,13 +125,9 @@ static void ps_call_back(void *p) /* There are three string - model name/serial/model ver */ if ((k < curl_data_loc_psu_model_name) || (k > curl_data_loc_psu_model_ver)) { - /* To avoid to get error char in first item */ - if (k == 0) - ps[k] = atoi(str+1); - else - ps[k] = atoi(str); - } - else + ps[k] = atoi(str); + } + else { switch (k) { diff --git a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/thermali.c b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/thermali.c index b645d07a6..f847a007e 100644 --- a/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/thermali.c +++ b/packages/platforms/accton/x86-64/as9516-32d/onlp/builds/x86_64_accton_as9516_32d/module/src/thermali.c @@ -123,8 +123,8 @@ void tmp_call_back(void *p) AIM_LOG_ERROR("Failed CURL response data.\n"); return; } - - i = data_loc_start - ptr; + /* Start to parse from the first value, ignore '[' */ + i = data_loc_start - ptr + 1; while (ptr[i] && ptr[i] != ']') { j = 0; @@ -139,10 +139,7 @@ void tmp_call_back(void *p) if (k < curl_data_thermal_num) { - if (k == 0) - tmp[k] = atoi(str+1); - else - tmp[k] = atoi(str); + tmp[k] = atoi(str); k++; }