diff --git a/modules/common/appspawn_encaps.c b/modules/common/appspawn_encaps.c index 6d492d80bf6d7f015836519a07155f0a6a53b6a4..f5c11a25a624e14ac5cb13132bd419b4c3c3c538 100644 --- a/modules/common/appspawn_encaps.c +++ b/modules/common/appspawn_encaps.c @@ -140,7 +140,7 @@ APPSPAWN_STATIC int AddPermissionStrToValue(const char *valueStr, UserEncap *enc return 0; } -APPSPAWN_STATIC int AddPermissionIntArrayToValue(cJSON *arrayItem, UserEncap *encap, int arraySize) +APPSPAWN_STATIC int AddPermissionIntArrayToValue(cJSON *arrayItem, UserEncap *encap, uint32_t arraySize) { uint32_t valueLen = sizeof(int) * arraySize; APPSPAWN_CHECK(valueLen <= OH_ENCAPS_VALUE_MAX_LEN, return APPSPAWN_ARG_INVALID, @@ -164,7 +164,7 @@ APPSPAWN_STATIC int AddPermissionIntArrayToValue(cJSON *arrayItem, UserEncap *en return 0; } -APPSPAWN_STATIC int AddPermissionBoolArrayToValue(cJSON *arrayItem, UserEncap *encap, int arraySize) +APPSPAWN_STATIC int AddPermissionBoolArrayToValue(cJSON *arrayItem, UserEncap *encap, uint32_t arraySize) { uint32_t valueLen = sizeof(bool) * arraySize; APPSPAWN_CHECK(valueLen <= OH_ENCAPS_VALUE_MAX_LEN, return APPSPAWN_ARG_INVALID, @@ -222,7 +222,7 @@ APPSPAWN_STATIC int AddPermissionStrArrayToValue(cJSON *arrayItem, UserEncap *en APPSPAWN_STATIC int AddPermissionArrayToValue(cJSON *permissionItemArr, UserEncap *encap) { - int arraySize = cJSON_GetArraySize(permissionItemArr); + uint32_t arraySize = (uint32_t)cJSON_GetArraySize(permissionItemArr); if (arraySize == 0) { return APPSPAWN_ARG_INVALID; } @@ -349,7 +349,7 @@ static int SpawnSetMaxPids(AppSpawningCtx *property, UserEncaps *encapsInfo) APPSPAWN_CHECK(encapsInfo->encapsCount < OH_ENCAPS_MAX_COUNT, return APPSPAWN_ARG_INVALID, "Encaps count is more than 64, cannot set permissions"); - int count = encapsInfo->encapsCount; + uint32_t count = encapsInfo->encapsCount; int ret = strcpy_s(encapsInfo->encap[count].key, OH_ENCAPS_KEY_MAX_LEN, APP_OHOS_ENCAPS_FORK_KEY); APPSPAWN_CHECK_ONLY_EXPER(ret == EOK, return APPSPAWN_SYSTEM_ERROR); diff --git a/test/mock/app_spawn_stub.h b/test/mock/app_spawn_stub.h index d451750eabff564ed08e0f85cb9fef7ab8b87df5..5abe32760896ef46cc6b547f81a4c3accd6e16ae 100644 --- a/test/mock/app_spawn_stub.h +++ b/test/mock/app_spawn_stub.h @@ -142,8 +142,8 @@ int AddPermissionItemToEncapsInfo(UserEncap *encap, cJSON *permissionItem); void FreeEncapsInfo(UserEncaps *encapsInfo); int SpawnSetEncapsPermissions(AppSpawnMgr *content, AppSpawningCtx *property); int WriteEncapsInfo(int fd, AppSpawnEncapsBaseType encapsType, const void *encapsInfo, uint32_t flag); -int AddPermissionIntArrayToValue(cJSON *arrayItem, UserEncap *encap, int arraySize); -int AddPermissionBoolArrayToValue(cJSON *arrayItem, UserEncap *encap, int arraySize); +int AddPermissionIntArrayToValue(cJSON *arrayItem, UserEncap *encap, uint32_t arraySize); +int AddPermissionBoolArrayToValue(cJSON *arrayItem, UserEncap *encap, uint32_t arraySize); int AddPermissionStrArrayToValue(cJSON *arrayItem, UserEncap *encap); int AddPermissionArrayToValue(cJSON *permissionItemArr, UserEncap *encap);