From de13465702f67f338023876ae00284b8d30aeb2f Mon Sep 17 00:00:00 2001 From: yudechen Date: Mon, 23 May 2022 10:08:31 +0800 Subject: [PATCH] fixed 0f9ac24 from https://gitee.com/yudechen/developtools_syscap_codec/pulls/44 fix mix signed and unsigned numbers. Signed-off-by: yudechen Change-Id: Ieca1e60da1619b6b107692a1b8dae58a87e82ae2 --- src/create_pcid.c | 8 +++++++- src/syscap_tool.c | 5 +++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/create_pcid.c b/src/create_pcid.c index 2ddac79..ea640b4 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -216,7 +216,13 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private"); if (jsonPriSyscapObj != NULL && cJSON_IsArray(jsonPriSyscapObj)) { - privateCapSize = cJSON_GetArraySize(jsonPriSyscapObj); + ret = cJSON_GetArraySize(jsonPriSyscapObj); + if (ret < 0) { + PRINT_ERR("get \"private syscap\" array size failed\n"); + ret = -1; + goto FREE_CONVERT_OUT; + } + privateCapSize = (uint32_t)ret; } else if (jsonPriSyscapObj == NULL) { privateCapSize = 0; } else { diff --git a/src/syscap_tool.c b/src/syscap_tool.c index a8053cf..f8e8cad 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -627,12 +627,13 @@ int32_t RPCIDEncode(char *inputFile, char *outDirPath) goto FREE_CONTEXT_OUT; } - sysCapSize = cJSON_GetArraySize(sysCapPtr); - if (sysCapSize < 0) { + ret = cJSON_GetArraySize(sysCapPtr); + if (ret < 0) { PRINT_ERR("get \"syscap\" array size failed\n"); ret = -1; goto FREE_CONTEXT_OUT; } + sysCapSize = (uint32_t)ret; // 2, to save SysCaptype & SysCapLength convertedBufLen += (2 * sizeof(uint16_t) + sysCapSize * SINGLE_FEAT_LENGTH); -- Gitee