fix: restore wrong modify of syscap_define.h.

- restore syscap  modify.
- update compile-time syscap define check progarm.

Signed-off-by: yudechen <chenyude@huawei.com>
Change-Id: I3d1116c8095a02fc039c0a77af2bd25d50f236c8
This commit is contained in:
yudechen
2022-12-06 19:02:22 +08:00
committed by chenyude
parent 22ff2fd9c5
commit fc727df793
4 changed files with 46 additions and 20 deletions
+27 -8
View File
@@ -18,21 +18,40 @@
#include <stdlib.h>
#include "syscap_define.h"
int main(void)
int CheckSortBySyscapNum()
{
size_t size = sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
size_t flag = 0;
int size = (int)sizeof(g_arraySyscap) / sizeof(SyscapWithNum);
int flag = 0;
for (size_t i = 0; i < size; i++) {
for (int i = 0; i < size; i++) {
if (g_arraySyscap[i].num != i) {
printf("[Error][syscap_define.h]: %s -> num(%u) should be %zu.\n",
printf("[ERROR][syscap_define.h]: %s -> num(%u) should be %d.\n",
g_arraySyscap[i].str, g_arraySyscap[i].num, i);
flag++;
}
}
if (flag == 0) {
return 0;
} else {
return flag;
}
int CheckSyscapNumOrder()
{
if (COMMUNICATION_NETMANAGER_VPN != 227) { // 227, special number
printf("[ERROR][syscap_define.h]: "
"enum value 'COMMUNICATION_NETMANAGER_VPN' should be 227. "
"Please don't change original SyscapNum's enum value order, "
"and add the new enum value at the end.\n");
return 1;
}
return 0;
}
int main(void)
{
if (CheckSyscapNumOrder() != 0) {
return -1;
}
if (CheckSortBySyscapNum() != 0) {
return -1;
}
return 0;
}