diff --git a/interfaces/inner_api/syscap_interface.c b/interfaces/inner_api/syscap_interface.c index c9352970c6697e8c666d4dc314525a1492ee5f6b..c85b66a65c89cc425a7e999af1601e686f32a1e5 100644 --- a/interfaces/inner_api/syscap_interface.c +++ b/interfaces/inner_api/syscap_interface.c @@ -516,10 +516,6 @@ char *DecodeRpcidToStringFormat(const char *inputFile) } PartSysCapAndOutBuffer(freeAfterDecodeRpcidInfo, outBuffer, priSyscapArray, sysCapArray); - - free(priSyscapArray); - priSyscapArray = NULL; - return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID, outBuffer); } diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 5663b64535538b13a9bca2c5af1dbd1b2dcf1182..3bcd76a6d3c68624f4f1c97647e16a2f5e8e67f1 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -141,10 +141,9 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath) gJsonObjectSysCap.cjsonObjectRoot = NULL; gJsonObjectSysCap.sysCapPtr = NULL; - int32_t ret = GetFileContext(inputFile, &contextBuffer, &bufferLen); - if (ret != 0) { + if (GetFileContext(inputFile, &contextBuffer, &bufferLen) != 0) { PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile); - return ret; + return -1; } gJsonObjectSysCap.cjsonObjectRoot = cJSON_ParseWithLength(contextBuffer, bufferLen); @@ -161,7 +160,7 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath) FREE_CONTEXT_OUT_RPCID_ENCODE, -1); } - ret = cJSON_GetArraySize(gJsonObjectSysCap.sysCapPtr); + int32_t ret = cJSON_GetArraySize(gJsonObjectSysCap.sysCapPtr); if (ret < 0) { PRINT_ERR("get \"syscap\" array size failed\n"); return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, NULL, contextBuffer, @@ -182,9 +181,10 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath) if (FillOsCapLength(convertedBuffer, contextBuffer, gJsonObjectSysCap, sysCapSize, ret) == -1) { return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer, - FREE_CONVERT_OUT_RPCID_ENCODE, ret); + FREE_CONVERT_OUT_RPCID_ENCODE, -1); } - if (ConvertedContextSaveAsFile(outputPath, "rpcid.sc", convertedBuffer, convertedBufLen) != 0) { + ret = ConvertedContextSaveAsFile(outputPath, "rpcid.sc", convertedBuffer, convertedBufLen); + if (ret != 0) { PRINT_ERR("ConvertedContextSaveAsFile failed, outputPath:%s, filename:rpcid.sc\n", outputPath); } return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer,