From 68564b3392682030fd08060a6331508dbe331761 Mon Sep 17 00:00:00 2001 From: yudechen Date: Mon, 13 Jun 2022 10:18:41 +0800 Subject: [PATCH 1/3] change syscap_tool parameters judegement. Signed-off-by: yudechen Change-Id: I12ddfb81501508bb35b1a76e7d2e0fb2a22aca87 --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 964efa9..09453b4 100644 --- a/src/main.c +++ b/src/main.c @@ -80,8 +80,8 @@ int main(int argc, char **argv) break; case 'C': pcidfile = optarg; - if (optind < 0 || optind > argc) { - PRINT_ERR("Input file path too few or too many.\n"); + if (argc != 4 || optind < 0 || optind >= argc) { // 4, argc of ./syscap_tool -C f1 f2 + PRINT_ERR("Input file too few or too many.\n"); return -1; } rpcidfile = argv[optind]; -- Gitee From eeb72b1c3051309a85d8601b5166041c4715be66 Mon Sep 17 00:00:00 2001 From: yudechen Date: Mon, 13 Jun 2022 14:22:46 +0800 Subject: [PATCH 2/3] fix mix use signed and unsigned. Signed-off-by: yudechen Change-Id: Ie5340cb0a8f41eca9b661d9fccb94d4915ae5e88 --- interfaces/inner_api/syscap_interface.c | 8 ++++---- src/syscap_tool.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index f5a53ad..3e2f82d 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -451,7 +451,7 @@ char *DecodeRpcidToStringFormat(char *inputFile) // malloc for save private syscap string priSyscapArray = (char *)malloc(sysCapArraySize * SINGLE_FEAT_LENGTH); if (priSyscapArray == NULL) { - PRINT_ERR("malloc(%u) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH); + PRINT_ERR("malloc(%u) failed.\n", (uint32_t)sysCapArraySize * SINGLE_FEAT_LENGTH); goto FREE_MALLOC_OSSYSCAP; } (void)memset_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH, @@ -462,7 +462,7 @@ char *DecodeRpcidToStringFormat(char *inputFile) cJSON *cJsonItem = cJSON_GetArrayItem(sysCapArray, i); cJsonTemp = cJSON_GetObjectItem(sysCapDefine, cJsonItem->valuestring); if (cJsonTemp != NULL) { - osSysCapIndex[indexOs++] = cJsonTemp->valueint; + osSysCapIndex[indexOs++] = (uint16_t)(cJsonTemp->valueint); } else { ret = strncpy_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH, cJsonItem->valuestring, SINGLE_FEAT_LENGTH - 1); @@ -483,8 +483,8 @@ char *DecodeRpcidToStringFormat(char *inputFile) goto FREE_MALLOC_PRISYSCAP; } - uint16_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER - + (SINGLE_FEAT_LENGTH + 1) * sysCapArraySize; + uint32_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER + + (SINGLE_FEAT_LENGTH + 1) * (uint32_t)sysCapArraySize; outBuffer = (char *)malloc(outBufferLen); if (outBuffer == NULL) { PRINT_ERR("malloc(%u) failed.\n", outBufferLen); diff --git a/src/syscap_tool.c b/src/syscap_tool.c index c2cb265..385ebc5 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -479,7 +479,7 @@ int32_t DecodeRpcidToString(char *inputFile, char *outDirPath) // malloc for save private syscap string priSyscapArray = (char *)malloc(sysCapArraySize * SINGLE_FEAT_LENGTH); if (priSyscapArray == NULL) { - PRINT_ERR("malloc(%u) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH); + PRINT_ERR("malloc(%d) failed.\n", sysCapArraySize * SINGLE_FEAT_LENGTH); goto FREE_MALLOC_OSSYSCAP; } (void)memset_s(priSyscapArray, sysCapArraySize * SINGLE_FEAT_LENGTH, -- Gitee From ceb9a02bf4714729cfd085e2346ea9bf9f65452a Mon Sep 17 00:00:00 2001 From: yudechen Date: Tue, 14 Jun 2022 09:23:19 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yudechen Change-Id: Icb6143ad685fd20e6a0f765e7c8ca7468ecbe867 --- test/unittest/common/syscap_codec_test.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/test/unittest/common/syscap_codec_test.cpp b/test/unittest/common/syscap_codec_test.cpp index 829ca2f..354f4d5 100644 --- a/test/unittest/common/syscap_codec_test.cpp +++ b/test/unittest/common/syscap_codec_test.cpp @@ -100,22 +100,6 @@ HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1) free(priOutput); } -/* - * @tc.name: DecodeRpcidToStringFormat - * @tc.desc: Check the DecodeRpcidToStringFormat Decoding. - * @tc.type: FUNC - */ -HWTEST_F(SyscapCodecTest, DecodeRpcidToStringFormat, TestSize.Level1) -{ - char inputfile[] = "/system/etc/rpcid.sc"; - char *out = DecodeRpcidToStringFormat(inputfile); - EXPECT_TRUE(out); - if (out != NULL) { - printf("%s\n", out); - free(out); - } -} - /* * @tc.name: ComparePcidString * @tc.desc: Check the DecodeRpcidToStringFormat Decoding. -- Gitee