From b648f7b23b68c035850e90ed42e3493626ed8e08 Mon Sep 17 00:00:00 2001 From: lichao Date: Wed, 10 Jan 2024 15:15:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8C=89=E7=85=A7=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lichao --- interfaces/inner_api/syscap_interface.c | 13 ++++++------- src/create_pcid.c | 2 +- src/syscap_tool.c | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 9fd163b..81ee2e8 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -327,7 +327,6 @@ static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo fr cJSON *sysCapArray, const char *inputFile) { // trans to string format - freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj(); sysCapArray = cJSON_GetObjectItem(freeAfterDecodeRpcidInfo.rpcidRoot, "syscap"); if (sysCapArray == NULL || !cJSON_IsArray(sysCapArray)) { PRINT_ERR("Get syscap failed. Input file: %s\n", inputFile); @@ -404,6 +403,7 @@ static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco uint16_t indexPri = 0; cJSON *cJsonTemp = NULL; + freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj(); (void)memset_s(priSyscapArray, freeAfterDecodeRpcidInfo.sysCapArraySize * SINGLE_SYSCAP_LEN, 0, freeAfterDecodeRpcidInfo.sysCapArraySize * SINGLE_SYSCAP_LEN); freeAfterDecodeRpcidInfo.priSyscap = priSyscapArray; @@ -492,7 +492,6 @@ char *DecodeRpcidToStringFormat(const char *inputFile) PRINT_ERR("Prase rpcid to json failed. Input file: %s\n", inputFile); return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, outBuffer); } - ret = TransStringFormatAndSaveSyscap(freeAfterDecodeRpcidInfo, sysCapArray, inputFile); if (ret == -1) { return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_WHOLE_SYSCAP_AFTER_DECODE_RPCID, outBuffer); @@ -533,7 +532,7 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result, const size_t allSyscapNum, uint32_t i, uint32_t blockBits) { - int32_t flag = 0; + int32_t ret = 0; for (uint8_t k = 0; k < INT_BIT; k++) { if (blockBits & (1U << k)) { char *tempSyscap = (char *)malloc(sizeof(char) * SINGLE_SYSCAP_LEN); @@ -542,8 +541,8 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp FreeCompareError(result); return -1; } - flag = CopySyscopToRet(pcidPriSyscapInfo, allSyscapNum, tempSyscap, i, k); - if (flag != EOK) { + ret = CopySyscopToRet(pcidPriSyscapInfo, allSyscapNum, tempSyscap, i, k); + if (ret != EOK) { PRINT_ERR("strcpy_s failed.\n"); FreeCompareError(result); return -1; @@ -551,11 +550,11 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap; } } - return 0; + return ret; } static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo, - uint32_t pcidOsAarry[PCID_OUT_BUFFER], uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result, + const uint32_t pcidOsAarry[PCID_OUT_BUFFER], const uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result, const size_t allSyscapNum) { uint32_t i; diff --git a/src/create_pcid.c b/src/create_pcid.c index 7ad15aa..cea4e57 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -384,7 +384,6 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL static int32_t CheckSysCapObj(struct FreeDecodePcidJsonInfo freePcidJsonInfo, PCIDMain *pcidMain, uint32_t contextBufLen, int32_t ret) { - freePcidJsonInfo.flag = 0; if (freePcidJsonInfo.sysCapObj == NULL) { PRINT_ERR("cJSON_CreateObject failed\n"); freePcidJsonInfo.flag = -1; @@ -456,6 +455,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) freePcidJsonInfo.contextBuffer = NULL; freePcidJsonInfo.jsonRootObj = NULL; freePcidJsonInfo.sysCapObj = NULL; + freePcidJsonInfo.flag = 0; ret = GetFileContext(inputFile, &freePcidJsonInfo.contextBuffer, (uint32_t *)&contextBufLen); if (ret != 0) { diff --git a/src/syscap_tool.c b/src/syscap_tool.c index cf66e7d..323c6b8 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -450,6 +450,7 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL; freeAfterEncodeRpcidscInfo.sysCapDefine = NULL; freeAfterEncodeRpcidscInfo.rpcidRoot = NULL; + freeAfterEncodeRpcidscInfo.outBuffer =NULL; freeAfterEncodeRpcidscInfo.contextBuffer = NULL; freeAfterEncodeRpcidscInfo.type = 0; freeAfterEncodeRpcidscInfo.flag = 0; From 85db000c39161b748e2b9144e5f69cfc8093d79c Mon Sep 17 00:00:00 2001 From: lichao Date: Wed, 10 Jan 2024 15:43:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8C=89=E7=85=A7=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lichao --- src/syscap_tool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 323c6b8..ff4e084 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -450,7 +450,7 @@ int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath) freeAfterEncodeRpcidscInfo.osSysCapIndex = NULL; freeAfterEncodeRpcidscInfo.sysCapDefine = NULL; freeAfterEncodeRpcidscInfo.rpcidRoot = NULL; - freeAfterEncodeRpcidscInfo.outBuffer =NULL; + freeAfterEncodeRpcidscInfo.outBuffer = NULL; freeAfterEncodeRpcidscInfo.contextBuffer = NULL; freeAfterEncodeRpcidscInfo.type = 0; freeAfterEncodeRpcidscInfo.flag = 0;