mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 10:21:25 -04:00
add const to some formal parameters.
Signed-off-by: yudechen <chenyude@huawei.com> Change-Id: I4e3659531872b1cc3dae496518cc03bdb6cbe3e2
This commit is contained in:
@@ -36,7 +36,7 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath);
|
||||
int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath);
|
||||
/* in: pcidFile, rpcidFile */
|
||||
int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile);
|
||||
int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArraySize,
|
||||
int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uint32_t osArraySize,
|
||||
char **priSyscap, uint32_t *priSyscapLen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -378,7 +378,7 @@ FREE_SYSCAP_OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t CheckRpcidFormat(const char *inputFile, char **Buffer, uint32_t *Len)
|
||||
static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *Len)
|
||||
{
|
||||
uint32_t bufferLen;
|
||||
uint16_t sysCaptype, sysCapLength;
|
||||
@@ -409,7 +409,7 @@ static int32_t CheckRpcidFormat(const char *inputFile, char **Buffer, uint32_t *
|
||||
return -1;
|
||||
}
|
||||
|
||||
*Buffer = contextBuffer;
|
||||
*buffer = contextBuffer;
|
||||
*Len = bufferLen;
|
||||
return 0;
|
||||
}
|
||||
@@ -498,8 +498,8 @@ char *DecodeRpcidToStringFormat(const char *inputFile)
|
||||
goto FREE_MALLOC_PRISYSCAP;
|
||||
}
|
||||
|
||||
uint16_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER
|
||||
+ SINGLE_SYSCAP_LEN * indexPri;
|
||||
uint16_t outBufferLen = U32_TO_STR_MAX_LEN * RPCID_OUT_BUFFER +
|
||||
SINGLE_SYSCAP_LEN * indexPri;
|
||||
outBuffer = (char *)malloc(outBufferLen);
|
||||
if (outBuffer == NULL) {
|
||||
PRINT_ERR("malloc(%u) failed.\n", outBufferLen);
|
||||
@@ -545,12 +545,12 @@ FREE_CONTEXT_OUT:
|
||||
return outBuffer;
|
||||
}
|
||||
|
||||
int32_t ComparePcidString(char *pcidString, char *rpcidString, CompareError *result)
|
||||
int32_t ComparePcidString(const char *pcidString, const char *rpcidString, CompareError *result)
|
||||
{
|
||||
int32_t ret;
|
||||
int32_t versionFlag = 0;
|
||||
int32_t ossyscapFlag = 0;
|
||||
int32_t prisyscapFlag = 0;
|
||||
uint16_t versionFlag = 0;
|
||||
uint16_t ossyscapFlag = 0;
|
||||
uint16_t prisyscapFlag = 0;
|
||||
char *pcidPriSyscap = NULL;
|
||||
char *rpcidPriSyscap = NULL;
|
||||
bool priSysFound;
|
||||
@@ -631,10 +631,10 @@ int32_t ComparePcidString(char *pcidString, char *rpcidString, CompareError *res
|
||||
priSysFound = false;
|
||||
}
|
||||
|
||||
if (versionFlag) {
|
||||
if (versionFlag > 0) {
|
||||
ret |= 0x1 << 0;
|
||||
}
|
||||
if (ossyscapFlag || prisyscapFlag) {
|
||||
if (ossyscapFlag > 0 || prisyscapFlag > 0) {
|
||||
ret |= 0x1 << 1;
|
||||
result->missSyscapNum = ossyscapFlag + prisyscapFlag;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile);
|
||||
* result.syscap[] is the array of points to syscap strings.
|
||||
* free variable result by function FreeCompareError.
|
||||
*/
|
||||
int32_t ComparePcidString(char *pcidString, char *rpcidString, CompareError *result);
|
||||
int32_t ComparePcidString(const char *pcidString, const char *rpcidString, CompareError *result);
|
||||
int32_t FreeCompareError(CompareError *result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
+23
-4
@@ -564,11 +564,12 @@ FREE_CONTEXT_OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArraySize,
|
||||
int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uint32_t osArraySize,
|
||||
char **priSyscap, uint32_t *priSyscapLen)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
uint32_t i, inputLen;
|
||||
uint32_t i;
|
||||
uint32_t inputLen = strlen(inputString);
|
||||
uint32_t count = 0;
|
||||
char *temp = NULL;
|
||||
char *tok = NULL;
|
||||
@@ -578,11 +579,26 @@ int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArra
|
||||
return -1;
|
||||
}
|
||||
|
||||
inputLen = strlen(input);
|
||||
// copy to temp string input
|
||||
char *input = (char *)malloc(strlen(inputString) + 1);
|
||||
if (input == NULL) {
|
||||
PRINT_ERR("malloc failed.\n");
|
||||
return -1;
|
||||
}
|
||||
ret = strcpy_s(input, inputLen + 1, inputString);
|
||||
if (ret != EOK) {
|
||||
PRINT_ERR("strcpy_s failed.\n");
|
||||
free(input);
|
||||
return -1;
|
||||
}
|
||||
input[inputLen] = '\0';
|
||||
|
||||
// get os syscap data
|
||||
for (i = 0; i < PCID_OUT_BUFFER; i++) {
|
||||
ret = sscanf_s(input, "%u,%s", &osArray[i], input, inputLen);
|
||||
if (ret == -1) {
|
||||
PRINT_ERR("sscanf_s failed.\n");
|
||||
free(input);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -603,6 +619,7 @@ int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArra
|
||||
char *priSysCapOut = (char *)malloc(SINGLE_SYSCAP_LEN * count);
|
||||
if (priSysCapOut == NULL) {
|
||||
PRINT_ERR("sscanf_s failed.\n");
|
||||
free(input);
|
||||
return -1;
|
||||
}
|
||||
(void)memset_s(priSysCapOut, SINGLE_SYSCAP_LEN * count, 0, SINGLE_SYSCAP_LEN * count);
|
||||
@@ -614,6 +631,7 @@ int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArra
|
||||
temp, SINGLE_SYSCAP_LEN - 1);
|
||||
if (ret != EOK) {
|
||||
PRINT_ERR("strncpy_s failed.\n");
|
||||
free(input);
|
||||
free(private);
|
||||
return -1;
|
||||
}
|
||||
@@ -625,6 +643,7 @@ int32_t SeparateSyscapFromString(char *input, uint32_t *osArray, uint32_t osArra
|
||||
*priSyscapLen = count;
|
||||
|
||||
SKIP_PRI_SYSCAP:
|
||||
free(input);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -667,7 +686,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile)
|
||||
uint16_t pcidVersion = NtohsInter(((PCIDMain *)pcidOsAarry)->apiVersion);
|
||||
uint16_t rpcidVersion = NtohsInter(((RPCIDHead *)rpcidOsAarry)->apiVersion);
|
||||
if (pcidVersion < rpcidVersion) {
|
||||
PRINT_ERR("Pcid version(%u) less than rpcid version(%u).\n", pcidVersion, rpcidVersion);
|
||||
printf("ERROR: Pcid version(%u) less than rpcid version(%u).\n", pcidVersion, rpcidVersion);
|
||||
versionFlag = 1;
|
||||
}
|
||||
// compare os syscap
|
||||
|
||||
@@ -127,16 +127,16 @@ HWTEST_F(SyscapCodecTest, DecodePrivateSyscap1, TestSize.Level1)
|
||||
HWTEST_F(SyscapCodecTest, ComparePcidString, TestSize.Level1)
|
||||
{
|
||||
CompareError result = {{0}, 0, 0};
|
||||
char pcidString[] = "263168,0,3473408,0,0,0,1634,0,0,0,0,0,0,0,0,0,0,"\
|
||||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SystemCapability.vendor.xxxxx3,"\
|
||||
"SystemCapability.device.xxxxx4";
|
||||
char rpcidString[] = "33588992,1766370052,65536,276824064,0,0,0,0,0,0,"\
|
||||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"\
|
||||
"SystemCapability.vendor.xxxxx1,SystemCapability.device.xxxxx2";
|
||||
char expect[][256] = {"SystemCapability.HiviewDFX.HiChecker",
|
||||
"SystemCapability.HiviewDFX.HiProfiler.HiDebug",
|
||||
"SystemCapability.vendor.xxxxx1",
|
||||
"SystemCapability.device.xxxxx2"};
|
||||
const char pcidString[] = "263168,0,3473408,0,0,0,1634,0,0,0,0,0,0,0,0,0,0,"\
|
||||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,SystemCapability.vendor.xxxxx3,"\
|
||||
"SystemCapability.device.xxxxx4";
|
||||
const char rpcidString[] = "33588992,1766370052,65536,276824064,0,0,0,0,0,0,"\
|
||||
"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"\
|
||||
"SystemCapability.vendor.xxxxx1,SystemCapability.device.xxxxx2";
|
||||
const char expect[][256] = {"SystemCapability.HiviewDFX.HiChecker",
|
||||
"SystemCapability.HiviewDFX.HiProfiler.HiDebug",
|
||||
"SystemCapability.vendor.xxxxx1",
|
||||
"SystemCapability.device.xxxxx2"};
|
||||
int32_t ret = ComparePcidString(pcidString, rpcidString, &result);
|
||||
EXPECT_EQ(ret, 3);
|
||||
EXPECT_EQ(result.targetApiVersion, 7);
|
||||
|
||||
Reference in New Issue
Block a user