change global variable arraySyscap to g_arraySyscap.

Signed-off-by: yudechen <chenyude@huawei.com>
Change-Id: Ia723dfc0bb1d78500e57ae823f33978c81ebd36b
This commit is contained in:
yudechen
2022-07-12 11:15:25 +08:00
parent 83673ddff2
commit 608261605e
4 changed files with 21 additions and 21 deletions
+2 -2
View File
@@ -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},
+6 -6
View File
@@ -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;
}
@@ -592,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);
+10 -10
View File
@@ -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;
+3 -3
View File
@@ -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;
}
@@ -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;
}
}