From a67ba5eb29ab4458ff6cf05849e92ef0ff56acab Mon Sep 17 00:00:00 2001 From: yudechen Date: Thu, 19 May 2022 17:46:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?bundle.json=20=E4=B8=AD=20syscap=20?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=B8=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yudechen Change-Id: I8a555628c837e98130b8318faa20dcf0efdfc3d1 --- include/syscap_define.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/syscap_define.h b/include/syscap_define.h index 24b2e73..5e47afc 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -280,7 +280,7 @@ static SyscapWithNum arraySyscap[] = { {"SystemCapability.Security.DeviceAuth", SECURITY_DEVICEAUTH}, {"SystemCapability.Security.DeviceSecurityLevel", SECURITY_DEVICESECURITYLEVEL}, {"SystemCapability.Security.Huks", SECURITY_HUKS}, - {"SystemCapability.Sensors.Medical_sensor", SENSORS_MEDICAL_SENSOR}, + {"SystemCapability.Sensors.Medical.Sensor", SENSORS_MEDICAL_SENSOR}, {"SystemCapability.Sensors.MiscDevice", SENSORS_MISCDEVICE}, {"SystemCapability.Sensors.Sensor", SENSORS_SENSOR}, {"SystemCapability.Sensors.Sensor.Lite", SENSORS_SENSOR_LITE}, @@ -305,4 +305,4 @@ static SyscapWithNum arraySyscap[] = { {"SystemCapability.UserIAM.UserIdm", USERIAM_USERIDM} }; -#endif // _SYSCAP_DEFINE_H \ No newline at end of file +#endif // _SYSCAP_DEFINE_H -- Gitee From 1240e5fa5c87dd5826784664d0811636afd80f10 Mon Sep 17 00:00:00 2001 From: yudechen Date: Fri, 20 May 2022 15:45:33 +0800 Subject: [PATCH 2/2] modify for codex check. Signed-off-by: yudechen Change-Id: I85252fc1e17387a67f2cf4a17771102752a66c53 --- include/syscap_define.h | 1 + interfaces/inner_api/syscap_interface.c | 4 ++-- napi/query_syscap.js | 2 +- src/create_pcid.c | 19 ++++++++++--------- src/syscap_tool.c | 25 +++++++++++++------------ 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/include/syscap_define.h b/include/syscap_define.h index 5e47afc..8958c3f 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -161,6 +161,7 @@ typedef enum SystemCapabilityNum { USERIAM_USERAUTH_FACEAUTH, USERIAM_USERAUTH_PINAUTH, USERIAM_USERIDM, + SYSCAP_NUM_MAX = 960 } SyscapNum; /* sort by enum */ diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index d96f95e..55125a8 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -70,8 +70,8 @@ static int32_t GetFileContext(char **contextBufPtr, uint32_t *bufferLen) FreeContextBuffer(contextBuffer); return -1; } - ret = fread(contextBuffer, statBuf.st_size, 1, fp); - if (ret != 1) { + size_t retFread = fread(contextBuffer, statBuf.st_size, 1, fp); + if (retFread != 1) { PRINT_ERR("read file(%s) failed, errno = %d\n", inputFile, errno); FreeContextBuffer(contextBuffer); (void)fclose(fp); diff --git a/napi/query_syscap.js b/napi/query_syscap.js index 6b9bfcd..6ea4023 100644 --- a/napi/query_syscap.js +++ b/napi/query_syscap.js @@ -1,7 +1,7 @@ // 首先需要通过requireInternal函数加载本模块 const systemCapability = requireInternal('systemCapability'); -// 这里定义了calc模块对外暴露的所有api +// 这里定义了模块对外暴露的所有api export default { querySystemCapabilities: systemCapability.querySystemCapabilities } \ No newline at end of file diff --git a/src/create_pcid.c b/src/create_pcid.c index efd478c..2ddac79 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -88,8 +88,8 @@ static int32_t GetFileContext(char *inputFile, char **contextBufPtr, uint32_t *c FreeContextBuffer(contextBuffer); return -1; } - ret = fread(contextBuffer, statBuf.st_size, 1, fp); - if (ret != 1) { + size_t retFread = fread(contextBuffer, statBuf.st_size, 1, fp); + if (retFread != 1) { PRINT_ERR("read file(%s) failed, errno = %d\n", path, errno); FreeContextBuffer(contextBuffer); (void)fclose(fp); @@ -195,23 +195,24 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) jsonSyscapObj = cJSON_GetObjectItem(jsonRootObj, "syscap"); if (jsonSyscapObj == NULL || !cJSON_IsObject(jsonSyscapObj)) { - PRINT_ERR("get \"syscap\" object failed, jsonSyscapObj = %p\n", jsonSyscapObj); + PRINT_ERR("get \"syscap\" object failed\n"); ret = -1; goto FREE_CONVERT_OUT; } jsonOsSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "os"); if (jsonOsSyscapObj == NULL || !cJSON_IsArray(jsonOsSyscapObj)) { - PRINT_ERR("get \"os\" array failed, jsonOsSyscapObj = %p\n", jsonOsSyscapObj); + PRINT_ERR("get \"os\" array failed\n"); ret = -1; goto FREE_CONVERT_OUT; } - osCapSize = cJSON_GetArraySize(jsonOsSyscapObj); - if (osCapSize < 0) { + ret = cJSON_GetArraySize(jsonOsSyscapObj); + if (ret < 0) { PRINT_ERR("get \"os\" array size failed\n"); ret = -1; goto FREE_CONVERT_OUT; } + osCapSize = (uint32_t)ret; jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private"); if (jsonPriSyscapObj != NULL && cJSON_IsArray(jsonPriSyscapObj)) { @@ -219,7 +220,7 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) } else if (jsonPriSyscapObj == NULL) { privateCapSize = 0; } else { - PRINT_ERR("get \"private\" array failed, jsonPriSyscapObj = %p\n", jsonPriSyscapObj); + PRINT_ERR("get \"private\" array failed\n"); ret = -1; goto FREE_CONVERT_OUT; } @@ -281,7 +282,7 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) jsonSyscapObj = cJSON_GetObjectItem(jsonRootObj, "api_version"); if (jsonSyscapObj == NULL || !cJSON_IsNumber(jsonSyscapObj)) { - PRINT_ERR("get \"api_version\" failed, jsonSyscapObj = %p\n", jsonSyscapObj); + PRINT_ERR("get \"api_version\" failed\n"); ret = -1; goto FREE_PCID_BUFFER_OUT; } @@ -306,7 +307,7 @@ int32_t CreatePCID(char *inputFile, char *outDirPath) jsonSyscapObj = cJSON_GetObjectItem(jsonRootObj, "manufacturer_id"); if (jsonSyscapObj == NULL || !cJSON_IsNumber(jsonSyscapObj)) { - PRINT_ERR("get \"manufacturer_id\" failed, jsonSyscapObj = %p\n", jsonSyscapObj); + PRINT_ERR("get \"manufacturer_id\" failed\n"); ret = -1; goto FREE_PCID_BUFFER_OUT; } diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 8846368..a8053cf 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -94,8 +94,8 @@ static int32_t GetFileContext(char *inputFile, char **contextBufPtr, uint32_t *b FreeContextBuffer(contextBuffer); return -1; } - ret = fread(contextBuffer, statBuf.st_size, 1, fp); - if (ret != 1) { + size_t retFread = fread(contextBuffer, statBuf.st_size, 1, fp); + if (retFread != 1) { PRINT_ERR("read file(%s) failed, errno = %d\n", path, errno); FreeContextBuffer(contextBuffer); (void)fclose(fp); @@ -193,36 +193,37 @@ int32_t PCIDEncode(char *inputFile, char *outDirPath) cjsonObjectPtr = cJSON_GetObjectItem(cjsonObjectRoot, "syscap"); if (cjsonObjectPtr == NULL || !cJSON_IsObject(cjsonObjectPtr)) { - PRINT_ERR("get \"syscap\" object failed, cjsonObjectPtr = %p\n", cjsonObjectPtr); + PRINT_ERR("get \"syscap\" object failed\n"); ret = -1; goto FREE_CONTEXT_OUT; } osCapPtr = cJSON_GetObjectItem(cjsonObjectPtr, "os"); if (osCapPtr == NULL || !cJSON_IsArray(osCapPtr)) { - PRINT_ERR("get \"os\" array failed, osCapPtr = %p\n", osCapPtr); + PRINT_ERR("get \"os\" array failed\n"); ret = -1; goto FREE_CONTEXT_OUT; } - osCapSize = cJSON_GetArraySize(osCapPtr); - if (osCapSize < 0) { + ret = cJSON_GetArraySize(osCapPtr); + if (ret < 0) { PRINT_ERR("get \"os\" array size failed\n"); ret = -1; goto FREE_CONTEXT_OUT; } + osCapSize = (uint32_t)ret; // 2, to save osSysCaptype & osSysCapLength convertedBufLen += (2 * sizeof(uint16_t) + osCapSize * SINGLE_FEAT_LENGTH); privateCapPtr = cJSON_GetObjectItem(cjsonObjectPtr, "private"); if (privateCapPtr != NULL && cJSON_IsArray(privateCapPtr)) { - privateCapSize = cJSON_GetArraySize(privateCapPtr); + privateCapSize = (uint32_t)cJSON_GetArraySize(privateCapPtr); // 2, to save privateSysCaptype & privateSysCapLength convertedBufLen += (2 * sizeof(uint16_t) * !!privateCapSize + privateCapSize * SINGLE_FEAT_LENGTH); } else if (privateCapPtr == NULL) { privateCapSize = 0; } else { - PRINT_ERR("get \"private\" array failed, privateCapPtr = %p\n", privateCapPtr); + PRINT_ERR("get \"private\" array failed\n"); ret = -1; goto FREE_CONTEXT_OUT; } @@ -239,7 +240,7 @@ int32_t PCIDEncode(char *inputFile, char *outDirPath) headPtr = (PCIDHead *)convertedBuffer; cjsonObjectPtr = cJSON_GetObjectItem(cjsonObjectRoot, "api_version"); if (cjsonObjectPtr == NULL || !cJSON_IsNumber(cjsonObjectPtr)) { - PRINT_ERR("get \"api_version\" failed, cjsonObjectPtr = %p\n", cjsonObjectPtr); + PRINT_ERR("get \"api_version\" failed\n"); ret = -1; goto FREE_CONVERT_OUT; } @@ -264,7 +265,7 @@ int32_t PCIDEncode(char *inputFile, char *outDirPath) cjsonObjectPtr = cJSON_GetObjectItem(cjsonObjectRoot, "manufacturer_id"); if (cjsonObjectPtr == NULL || !cJSON_IsNumber(cjsonObjectPtr)) { - PRINT_ERR("get \"manufacturer_id\" failed, cjsonObjectPtr = %p\n", cjsonObjectPtr); + PRINT_ERR("get \"manufacturer_id\" failed\n"); ret = -1; goto FREE_CONVERT_OUT; } @@ -334,7 +335,7 @@ int32_t PCIDEncode(char *inputFile, char *outDirPath) cjsonObjectPtr = cJSON_GetObjectItem(cjsonObjectRoot, "product"); if (cjsonObjectPtr == NULL || !cJSON_IsString(cjsonObjectPtr)) { - PRINT_ERR("get \"product\" failed, cjsonObjectPtr = %p\n", cjsonObjectPtr); + PRINT_ERR("get \"product\" failed\n"); ret = -1; goto FREE_CONVERT_OUT; } @@ -646,7 +647,7 @@ int32_t RPCIDEncode(char *inputFile, char *outDirPath) headPtr = (RPCIDHead *)convertedBuffer; apiVerItem = cJSON_GetObjectItem(cjsonObjectRoot, "api_version"); if (apiVerItem == NULL || !cJSON_IsNumber(apiVerItem)) { - PRINT_ERR("get \"api_version\" failed, apiVerItem = %p\n", apiVerItem); + PRINT_ERR("get \"api_version\" failed\n"); ret = -1; goto FREE_CONVERT_OUT; } -- Gitee