From a7d8518f091aa48234e6d9b8c45336cb48419d75 Mon Sep 17 00:00:00 2001 From: lichao Date: Thu, 21 Dec 2023 15:03:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=89=E7=85=A7=E7=BC=96=E7=A0=81=E8=A7=84?= =?UTF-8?q?=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 | 32 +++++++++++++++---------- napi/napi_query_syscap.cpp | 4 ++-- src/syscap_tool.c | 8 +++---- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index 6167ff8..35b3bea 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -323,8 +323,8 @@ FREE_SYSCAP_OUT: return ret; } -static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, cJSON *sysCapArray, - const char *inputFile) +static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, + cJSON *sysCapArray, const char *inputFile) { // trans to string format freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj(); @@ -339,7 +339,8 @@ static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo fr return -1; } // malloc for save os syscap index - freeAfterDecodeRpcidInfo.osSysCapIndex = (uint16_t *)malloc(sizeof(uint16_t) * freeAfterDecodeRpcidInfo.sysCapArraySize); + freeAfterDecodeRpcidInfo.osSysCapIndex = (uint16_t *)malloc(sizeof(uint16_t) + * freeAfterDecodeRpcidInfo.sysCapArraySize); if (freeAfterDecodeRpcidInfo.osSysCapIndex == NULL) { PRINT_ERR("malloc failed.\n"); return -1; @@ -398,7 +399,8 @@ static void PrintResultToOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco } static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, char *outBuffer, - char *priSyscapArray, cJSON *sysCapArray) { + char *priSyscapArray, cJSON *sysCapArray) +{ uint32_t i; int32_t ret = 0; uint16_t indexOs = 0; @@ -428,7 +430,8 @@ static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco } static char *FreeAfterDecodeRpcidToString(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, int32_t type, - char *outBuffer) { + char *outBuffer) +{ switch (type) { case FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID: free(freeAfterDecodeRpcidInfo.priSyscap); @@ -497,8 +500,9 @@ char *DecodeRpcidToStringFormat(const char *inputFile) return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID, outBuffer); } -static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const size_t allSyscapNum, char *tempSyscap, - uint32_t i, uint8_t k) { +static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const size_t allSyscapNum, + char *tempSyscap, uint32_t i, uint8_t k) +{ uint32_t pos = (i - 2) * INT_BIT + k; uint32_t t; for (t = 0; t < allSyscapNum; t++) { @@ -506,15 +510,16 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const break; } } - pcidPriSyscapInfo.ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str); // 2, header of pcid & rpcid + pcidPriSyscapInfo.ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str); + // 2, header of pcid & rpcid if (pcidPriSyscapInfo.ret != EOK) { return -1; } return 0; } -static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result, const size_t allSyscapNum, - uint32_t i, uint32_t blockBits) +static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result, + const size_t allSyscapNum, uint32_t i, uint32_t blockBits) { int32_t flag = 0; for (uint8_t k = 0; k < INT_BIT; k++) { @@ -531,14 +536,15 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp FreeCompareError(result); return -1; } - result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap; + result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap; } } return 0; } -static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo, uint32_t pcidOsAarry[PCID_OUT_BUFFER], - uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result, const size_t allSyscapNum) +static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo, + uint32_t pcidOsAarry[PCID_OUT_BUFFER], uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result, + const size_t allSyscapNum) { uint32_t i; int32_t ret = 0; diff --git a/napi/napi_query_syscap.cpp b/napi/napi_query_syscap.cpp index 4c92dc7..774599d 100644 --- a/napi/napi_query_syscap.cpp +++ b/napi/napi_query_syscap.cpp @@ -54,7 +54,7 @@ struct SystemCapabilityAsyncContext { }; static char* CalculateAllStringLength(char *priOutput, char osCapArray[PCID_MAIN_U32][U32_TO_STR_MAX_LEN], - char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer) + char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer) { bool retBool; errno_t err = EOK; @@ -112,7 +112,7 @@ static char* CalculateAllStringLength(char *priOutput, char osCapArray[PCID_MAIN } static char* FreeAfterGetSysCap(char *priOutput, char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer, - int32_t type) + int32_t type) { if (type == FREE_PRICAP_ARRAY_AFTER_GET_SYS_CAP) { free(priCapArray); diff --git a/src/syscap_tool.c b/src/syscap_tool.c index eb4961a..7db704a 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -87,7 +87,6 @@ static int32_t FillOsCapLength(char *convertedBuffer, char *contextBuffer, struc headPtr->apiVersion = HtonsInter((uint16_t)apiVerItem->valueint); headPtr->apiVersionType = 1; - fillTmpPtr = convertedBuffer + sizeof(RPCIDHead); *(uint16_t *)fillTmpPtr = HtonsInter(2); // 2, SysCap Type, 2: request Cap fillTmpPtr += sizeof(uint16_t); @@ -330,8 +329,8 @@ static int32_t PrintOutputToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEnco return ret; } -static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEncodeRpcidscInfo, - int32_t sysCapArraySize, cJSON *sysCapArray, char *outDirPath) +static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEncodeRpcidscInfo, + int32_t sysCapArraySize, cJSON *sysCapArray, char *outDirPath) { char *priSyscap = NULL; cJSON *cJsonTemp = NULL; @@ -373,7 +372,8 @@ static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo free outUint[0] = *(uint32_t *)freeAfterEncodeRpcidscInfo.contextBuffer; outUint[1] = *(uint32_t *)(freeAfterEncodeRpcidscInfo.contextBuffer + sizeof(uint32_t)); uint8_t *osOutUint = (uint8_t *)(outUint + 2); - if (SetOsSysCapBitMap(osOutUint, 120, freeAfterEncodeRpcidscInfo.osSysCapIndex, indexOs) != 0) { // 120, len of osOutUint + // 120, len of osOutUint + if (SetOsSysCapBitMap(osOutUint, 120, freeAfterEncodeRpcidscInfo.osSysCapIndex, indexOs) != 0) { PRINT_ERR("Set os syscap bit map failed.\n"); freeAfterEncodeRpcidscInfo.flag = 1; return ret;