mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 10:21:25 -04:00
!91 代码规范问题。(cherry-pick)
Merge pull request !91 from chenyude/cherry-pick-1657855422
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
#define SINGLE_SYSCAP_LEN (256 + 17)
|
||||
|
||||
typedef struct SystemCapabilityWithNum {
|
||||
char syscapStr[SINGLE_SYSCAP_LEN];
|
||||
char str[SINGLE_SYSCAP_LEN];
|
||||
uint16_t num;
|
||||
} SyscapWithNum;
|
||||
|
||||
@@ -181,7 +181,7 @@ typedef enum SystemCapabilityNum {
|
||||
} SyscapNum;
|
||||
|
||||
/* sort by enum */
|
||||
const static SyscapWithNum arraySyscap[] = {
|
||||
const static SyscapWithNum g_arraySyscap[] = {
|
||||
{"SystemCapability.Account.AppAccount", ACCOUNT_APPACCOUNT},
|
||||
{"SystemCapability.Account.OsAccount", ACCOUNT_OSACCOUNT},
|
||||
{"SystemCapability.Ace.UiAppearance", ACE_UIAPPEARANCE},
|
||||
|
||||
@@ -219,9 +219,9 @@ bool DecodeOsSyscap(const char input[PCID_MAIN_BYTES], char (**output)[SINGLE_SY
|
||||
*output = strSyscap;
|
||||
|
||||
for (i = 0; i < countOfSyscap; i++) {
|
||||
for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (arraySyscap[j].num == indexOfSyscap[i]) {
|
||||
nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, arraySyscap[j].syscapStr);
|
||||
for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (g_arraySyscap[j].num == indexOfSyscap[i]) {
|
||||
nRet = strcpy_s(*strSyscap, SINGLE_SYSCAP_LEN, g_arraySyscap[j].str);
|
||||
if (nRet != EOK) {
|
||||
printf("strcpy_s failed. error = %d\n", nRet);
|
||||
*outputCnt = 0;
|
||||
@@ -322,10 +322,10 @@ static int SetOsSysCapBitMap(uint8_t *out, uint16_t outLen, uint16_t *index, uin
|
||||
|
||||
static cJSON *CreateWholeSyscapJsonObj(void)
|
||||
{
|
||||
size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum);
|
||||
size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
for (size_t i = 0; i < numOfSyscapAll; i++) {
|
||||
cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num));
|
||||
cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num));
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -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;
|
||||
@@ -410,7 +410,7 @@ static int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *
|
||||
}
|
||||
|
||||
*buffer = contextBuffer;
|
||||
*Len = bufferLen;
|
||||
*len = bufferLen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -556,6 +556,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa
|
||||
bool priSysFound;
|
||||
uint32_t pcidPriSyscapLen, rpcidPriSyscapLen;
|
||||
uint32_t i, j, temp1, temp2;
|
||||
uint32_t retFlag = 0;
|
||||
uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0};
|
||||
uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0};
|
||||
|
||||
@@ -591,7 +592,7 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa
|
||||
return -1;
|
||||
}
|
||||
ret = strcpy_s(temp, sizeof(char) * SINGLE_SYSCAP_LEN,
|
||||
arraySyscap[(i - 2) * INT_BIT + k].syscapStr); // 2, header of pcid & rpcid
|
||||
g_arraySyscap[(i - 2) * INT_BIT + k].str); // 2, header of pcid & rpcid
|
||||
if (ret != EOK) {
|
||||
PRINT_ERR("strcpy_s failed.\n");
|
||||
FreeCompareError(result);
|
||||
@@ -632,13 +633,13 @@ int32_t ComparePcidString(const char *pcidString, const char *rpcidString, Compa
|
||||
}
|
||||
|
||||
if (versionFlag > 0) {
|
||||
ret |= 0x1 << 0;
|
||||
retFlag |= 0x1 << 0;
|
||||
}
|
||||
if (ossyscapFlag > 0 || prisyscapFlag > 0) {
|
||||
ret |= 0x1 << 1;
|
||||
retFlag |= 0x1 << 1;
|
||||
result->missSyscapNum = ossyscapFlag + prisyscapFlag;
|
||||
}
|
||||
return ret;
|
||||
return retFlag;
|
||||
}
|
||||
|
||||
int32_t FreeCompareError(CompareError *result)
|
||||
|
||||
+10
-10
@@ -158,10 +158,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename
|
||||
|
||||
static cJSON *CreateWholeSyscapJsonObj(void)
|
||||
{
|
||||
size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum);
|
||||
size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
for (size_t i = 0; i < numOfSyscapAll; i++) {
|
||||
cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num));
|
||||
cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num));
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -393,9 +393,9 @@ int32_t DecodePCID(char *inputFile, char *outDirPath)
|
||||
}
|
||||
}
|
||||
for (i = 0; i < countOfSyscap; i++) {
|
||||
for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (arraySyscap[j].num == indexOfSyscap[i]) {
|
||||
if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(arraySyscap[j].syscapStr))) {
|
||||
for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (g_arraySyscap[j].num == indexOfSyscap[i]) {
|
||||
if (!cJSON_AddItemToArray(capVectorPtr, cJSON_CreateString(g_arraySyscap[j].str))) {
|
||||
printf("cJSON_AddItemToArray or cJSON_CreateString failed\n");
|
||||
ret = -1;
|
||||
goto FREE_VECTOR_OUT;
|
||||
@@ -614,11 +614,11 @@ static int32_t AddOsSyscapToJsonObj(uint32_t *osSyscapArray, uint32_t osSyscapAr
|
||||
}
|
||||
|
||||
for (i = 0; i < osSyscapCount; i++) {
|
||||
for (j = 0; j < sizeof(arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (index[i] != arraySyscap[j].num) {
|
||||
for (j = 0; j < sizeof(g_arraySyscap) / sizeof(SyscapWithNum); j++) {
|
||||
if (index[i] != g_arraySyscap[j].num) {
|
||||
continue;
|
||||
}
|
||||
if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(arraySyscap[j].syscapStr))) {
|
||||
if (!cJSON_AddItemToArray(sysCapArray, cJSON_CreateString(g_arraySyscap[j].str))) {
|
||||
PRINT_ERR("Add os syscap string to json failed.\n");
|
||||
free(sysCapArray);
|
||||
return -1;
|
||||
@@ -732,8 +732,8 @@ PARSE_FAILED:
|
||||
int32_t EncodePcidscToString(char *inputFile, char *outDirPath)
|
||||
{
|
||||
int32_t ret = 0;
|
||||
size_t bufferLen, privateSyscapLen;
|
||||
uint32_t i, j, outputLen;
|
||||
size_t bufferLen, privateSyscapLen, outputLen;
|
||||
uint32_t i, j;
|
||||
uint32_t *mainSyscap = NULL;
|
||||
uint16_t priSyscapCount = 0;
|
||||
char *contextBuffer = NULL;
|
||||
|
||||
+4
-4
@@ -174,10 +174,10 @@ static int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename
|
||||
|
||||
static cJSON *CreateWholeSyscapJsonObj(void)
|
||||
{
|
||||
size_t numOfSyscapAll = sizeof(arraySyscap) / sizeof(SyscapWithNum);
|
||||
size_t numOfSyscapAll = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
|
||||
cJSON *root = cJSON_CreateObject();
|
||||
for (size_t i = 0; i < numOfSyscapAll; i++) {
|
||||
cJSON_AddItemToObject(root, arraySyscap[i].syscapStr, cJSON_CreateNumber(arraySyscap[i].num));
|
||||
cJSON_AddItemToObject(root, g_arraySyscap[i].str, cJSON_CreateNumber(g_arraySyscap[i].num));
|
||||
}
|
||||
return root;
|
||||
}
|
||||
@@ -569,7 +569,7 @@ int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uin
|
||||
{
|
||||
int32_t ret = 0;
|
||||
uint32_t i;
|
||||
uint32_t inputLen = strlen(inputString);
|
||||
size_t inputLen = strlen(inputString);
|
||||
uint32_t count = 0;
|
||||
char *temp = NULL;
|
||||
char *tok = NULL;
|
||||
@@ -699,7 +699,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile)
|
||||
for (uint8_t k = 0; k < INT_BIT; k++) {
|
||||
if (temp2 & (0x1 << k)) {
|
||||
// 2, header of pcid & rpcid
|
||||
printf("Missing: %s\n", arraySyscap[(i - 2) * INT_BIT + k].syscapStr);
|
||||
printf("Missing: %s\n", g_arraySyscap[(i - 2) * INT_BIT + k].str);
|
||||
ossyscapFlag += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user