From 16deb2be023599b7eee0b864872ed12ff24cf8cb Mon Sep 17 00:00:00 2001 From: liutuantuan Date: Tue, 28 May 2024 21:26:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9D=99=E6=80=81=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E6=8C=87=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liutuantuan --- include/syscap_tool.h | 2 +- src/syscap_tool.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/syscap_tool.h b/include/syscap_tool.h index a606e32..e383c27 100644 --- a/include/syscap_tool.h +++ b/include/syscap_tool.h @@ -32,7 +32,7 @@ int32_t PCIDEncode(char *inputFile, char *outputPath); /* in: inputFile, file name format: .sc, out: outputPath/.json */ int32_t PCIDDecode(char *inputFile, char *outputPath); /* in: inputFile, out: outputPath/rpcid.sc */ -int32_t RPCIDEncode(char *inputFile, char *outputPath); +static int32_t RPCIDEncode(char *inputFile, char *outputPath); /* in: inputFile, out: outputPath/rpcid.json */ int32_t RPCIDDecode(char *inputFile, char *outputPath); /* in: inputFile, out: outputPath/rpcid.json */ diff --git a/src/syscap_tool.c b/src/syscap_tool.c index e579d5e..5322170 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -36,6 +36,7 @@ #define SYSCAP_PREFIX_LEN 17 #define SINGLE_FEAT_LEN (SINGLE_SYSCAP_LEN - SYSCAP_PREFIX_LEN) +#define DOUBLE_SPACE 2 #define UINT8_BIT 8 #define INT_BIT 32 #define RPCID_OUT_BUFFER 32 @@ -132,7 +133,8 @@ static int32_t FreeAfterRPCIDEncode( return ret; } -int32_t RPCIDEncode(char *inputFile, char *outputPath) { +static int32_t RPCIDEncode(char *inputFile, char *outputPath) +{ char *contextBuffer = NULL; uint32_t bufferLen, sysCapSize; struct JsonObjectSysCap gJsonObjectSysCap; @@ -168,7 +170,7 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath) { // 2, to save SysCaptype & SysCapLength sysCapSize = (uint32_t) ret; uint32_t convertedBufLen = sizeof(RPCIDHead); - convertedBufLen += (2 * sizeof(uint16_t) + sysCapSize * SINGLE_FEAT_LEN); + convertedBufLen += (DOUBLE_SPACE * sizeof(uint16_t) + sysCapSize * SINGLE_FEAT_LEN); char *convertedBuffer = (char *) malloc(convertedBufLen); if (convertedBuffer == NULL) { PRINT_ERR("malloc failed\n");