修改静态告警指标

Signed-off-by: liutuantuan <liutuantuan1@huawei.com>
This commit is contained in:
liutuantuan
2024-05-28 20:41:42 +08:00
parent d24cb149f9
commit 6183e1c552
+22 -20
View File
@@ -132,18 +132,14 @@ static int32_t FreeAfterRPCIDEncode(
return ret;
}
int32_t RPCIDEncode(char *inputFile, char *outputPath)
{
int32_t ret;
int32_t RPCIDEncode(char *inputFile, char *outputPath) {
char *contextBuffer = NULL;
uint32_t bufferLen, sysCapSize;
char *convertedBuffer = NULL;
uint32_t convertedBufLen = sizeof(RPCIDHead);
struct JsonObjectSysCap gJsonObjectSysCap;
gJsonObjectSysCap.cjsonObjectRoot = NULL;
gJsonObjectSysCap.sysCapPtr = NULL;
ret = GetFileContext(inputFile, &contextBuffer, &bufferLen);
int32_t ret = GetFileContext(inputFile, &contextBuffer, &bufferLen);
if (ret != 0) {
PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile);
return ret;
@@ -152,40 +148,46 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath)
gJsonObjectSysCap.cjsonObjectRoot = cJSON_ParseWithLength(contextBuffer, bufferLen);
if (gJsonObjectSysCap.cjsonObjectRoot == NULL) {
PRINT_ERR("cJSON_Parse failed, context buffer is:\n%s\n", contextBuffer);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer, FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, null, contextBuffer,
FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
}
gJsonObjectSysCap.sysCapPtr = cJSON_GetObjectItem(gJsonObjectSysCap.cjsonObjectRoot, "syscap");
if (gJsonObjectSysCap.sysCapPtr == NULL || !cJSON_IsArray(gJsonObjectSysCap.sysCapPtr)) {
PRINT_ERR("get \"syscap\" object failed.\n");
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer, FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, null, contextBuffer,
FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
}
ret = cJSON_GetArraySize(gJsonObjectSysCap.sysCapPtr);
if (ret < 0) {
if (cJSON_GetArraySize(gJsonObjectSysCap.sysCapPtr) < 0) {
PRINT_ERR("get \"syscap\" array size failed\n");
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer, FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, null, contextBuffer,
FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
}
sysCapSize = (uint32_t)ret;
// 2, to save SysCaptype & SysCapLength
convertedBufLen += (2 * sizeof(uint16_t) + sysCapSize * SINGLE_FEAT_LEN);
convertedBuffer = (char *)malloc(convertedBufLen);
// 2, to save SysCaptype & SysCapLength
sysCapSize = (uint32_t) ret;
uint32_t convertedBufLen = sizeof(RPCIDHead);
convertedBufLen += (2 * sizeof(uint16_t) + sysCapSize * SINGLE_FEAT_LEN);
char *convertedBuffer = (char *) malloc(convertedBufLen);
if (convertedBuffer == NULL) {
PRINT_ERR("malloc failed\n");
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer, FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer,
FREE_CONTEXT_OUT_RPCID_ENCODE, -1);
}
(void)memset_s(convertedBuffer, convertedBufLen, 0, convertedBufLen);
(void) memset_s(convertedBuffer, convertedBufLen, 0, convertedBufLen);
ret = FillOsCapLength(convertedBuffer, contextBuffer, gJsonObjectSysCap, sysCapSize, ret);
ret = FillOsCapLength(convertedBuffer, contextBuffer, gJsonObjectSysCap, sysCapSize, ret);
if (ret == -1) {
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer,FREE_CONVERT_OUT_RPCID_ENCODE, ret);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer,
FREE_CONVERT_OUT_RPCID_ENCODE, ret);
}
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,FREE_CONVERT_OUT_RPCID_ENCODE, ret);
return FreeAfterRPCIDEncode(gJsonObjectSysCap.cjsonObjectRoot, convertedBuffer, contextBuffer,
FREE_CONVERT_OUT_RPCID_ENCODE, ret);
}
static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson)