diff --git a/security_lite/huks/common/hks_test_api_performance.c b/security_lite/huks/common/hks_test_api_performance.c index 49a5e45361fc60c436bfc9affa4a020f385dae6b..ca4e32e28c1677bec33783aa0844005d452a8279 100644 --- a/security_lite/huks/common/hks_test_api_performance.c +++ b/security_lite/huks/common/hks_test_api_performance.c @@ -28,7 +28,7 @@ int32_t HksGenerateKeyRun(const struct HksBlob *keyAlias, const struct HksParamSet *paramSetIn, struct HksParamSet *paramSetOut, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; /* if keyAlias exist, the key will be generated and refreshed */ for (uint32_t i = 0; i < performTimes; ++i) { ret = HksGenerateKey(keyAlias, paramSetIn, paramSetOut); @@ -42,7 +42,7 @@ int32_t HksGenerateKeyRun(const struct HksBlob *keyAlias, const struct HksParamS int32_t HksEncryptRun(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *plainText, struct HksBlob *cipherText, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriCipherTestSize = 0; if (cipherText != NULL) { oriCipherTestSize = cipherText->size; @@ -65,7 +65,7 @@ int32_t HksEncryptRun(const struct HksBlob *key, const struct HksParamSet *param int32_t HksDecryptRun(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *cipherText, struct HksBlob *plainText, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriPlainTextSize = 0; if (plainText != NULL) { oriPlainTextSize = plainText->size; @@ -87,7 +87,7 @@ int32_t HksDecryptRun(const struct HksBlob *key, const struct HksParamSet *param int32_t HksMacRun(const struct HksBlob *key, const struct HksParamSet *paramSet, const struct HksBlob *srcData, struct HksBlob *mac, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriMacSize = 0; if (mac != NULL) { oriMacSize = mac->size; @@ -109,7 +109,7 @@ int32_t HksMacRun(const struct HksBlob *key, const struct HksParamSet *paramSet, int32_t HksDeriveKeyRun(const struct HksParamSet *paramSet, const struct HksBlob *masterKey, struct HksBlob *derivedKey, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriDerivedKeySize = 0; if (derivedKey != NULL) { oriDerivedKeySize = derivedKey->size; @@ -136,7 +136,7 @@ int32_t HksDeleteKeyRun(const struct HksBlob *keyAlias, uint32_t performTimes) int32_t HksKeyExistRun(const struct HksBlob *keyAlias, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; for (uint32_t i = 0; i < performTimes; ++i) { ret = HksKeyExist(keyAlias, NULL); if (ret != HKS_SUCCESS) { @@ -148,7 +148,7 @@ int32_t HksKeyExistRun(const struct HksBlob *keyAlias, uint32_t performTimes) int32_t HksGenerateRandomRun(struct HksBlob *random, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriRandomSize = 0; if (random != NULL) { oriRandomSize = random->size; @@ -170,7 +170,7 @@ int32_t HksGenerateRandomRun(struct HksBlob *random, uint32_t performTimes) int32_t HksAgreeKeyRun(const struct HksParamSet *paramSet, const struct HksBlob *privateKey, const struct HksBlob *peerPublicKey, struct HksBlob *agreedKey, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriAgreedKeySize = 0; if (agreedKey != NULL) { oriAgreedKeySize = agreedKey->size; @@ -192,7 +192,7 @@ int32_t HksAgreeKeyRun(const struct HksParamSet *paramSet, const struct HksBlob int32_t HksHashRun(const struct HksParamSet *paramSet, const struct HksBlob *srcData, struct HksBlob *hash, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriHashSize = 0; if (hash != NULL) { oriHashSize = hash->size; @@ -215,7 +215,7 @@ int32_t HksHashRun(const struct HksParamSet *paramSet, int32_t HksBnExpModRun(struct HksBlob *x, const struct HksBlob *a, const struct HksBlob *e, const struct HksBlob *n, uint32_t performTimes) { - int32_t ret; + int32_t ret = 0; uint32_t oriXSize = 0; if (x != NULL) { oriXSize = x->size; diff --git a/security_lite/permission_posix/capability/src/ActsCapability.cpp b/security_lite/permission_posix/capability/src/ActsCapability.cpp index 018ffba685a348ea9c71db2bc326ffc8ad9a90a9..0097c41dcd45f34b88651ce6eff509ca8da104d4 100644 --- a/security_lite/permission_posix/capability/src/ActsCapability.cpp +++ b/security_lite/permission_posix/capability/src/ActsCapability.cpp @@ -508,7 +508,7 @@ char *GetCurrentPath() int CheckFsMount(const char *topDir, const char *topDirMountInfo) { const int lenMax = 100; - int len; + int len = 0; char buf[lenMax] = {0}; const char mountInfoFile[] = "/proc/mounts"; // check topDir exist diff --git a/security_lite/permission_posix/capability/src/ActsCapabilityTest.cpp b/security_lite/permission_posix/capability/src/ActsCapabilityTest.cpp index 40251dfd66d05065b5ddbfa1857956967c8c2433..2a852f00c9424447bc701e5d779949880fa07aa5 100644 --- a/security_lite/permission_posix/capability/src/ActsCapabilityTest.cpp +++ b/security_lite/permission_posix/capability/src/ActsCapabilityTest.cpp @@ -344,7 +344,7 @@ static int CapgetWithCaps(pid_t pid, unsigned int caps) */ HWTEST_F(CapabilityTestSuite, CapabilityTest0600, Function | MediumTest | Level2) { - int ret; + int ret = 0; int status1 = 0; int status2 = 0; // Preset action: Fork a sub process pid1 @@ -404,7 +404,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest0600, Function | MediumTest | Level2 */ HWTEST_F(CapabilityTestSuite, CapabilityTest0700, Function | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; pid_t pid = fork(); // Preset action: Fork a sub process ASSERT_TRUE(pid >= 0) << "======== Fork Error! ========="; @@ -454,7 +454,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest0700, Function | MediumTest | Level2 */ HWTEST_F(CapabilityTestSuite, CapabilityTest0800, Function | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); @@ -522,7 +522,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest0800, Function | MediumTest | Level2 */ HWTEST_F(CapabilityTestSuite, CapabilityTest0900, Security | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); @@ -559,7 +559,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest0900, Security | MediumTest | Level2 */ HWTEST_F(CapabilityTestSuite, CapabilityTest1000, Function | MediumTest | Level2) { - int ret; + int ret = 0; int status1 = 0; int status2 = 0; // Preset action: Fork a sub process pid1 @@ -623,7 +623,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest1000, Function | MediumTest | Level2 */ HWTEST_F(CapabilityTestSuite, CapabilityTest1100, Function | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; struct timespec tp = { 0 }; // Preset action: Fork a sub process @@ -821,7 +821,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest1500, Reliability | MediumTest | Lev */ HWTEST_F(CapabilityTestSuite, CapabilityTest1600, Reliability | MediumTest | Level3) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); @@ -901,7 +901,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest1700, Reliability | MediumTest | Lev */ HWTEST_F(CapabilityTestSuite, CapabilityTest1800, Reliability | MediumTest | Level3) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); @@ -939,7 +939,7 @@ HWTEST_F(CapabilityTestSuite, CapabilityTest1800, Reliability | MediumTest | Lev */ HWTEST_F(CapabilityTestSuite, CapabilityTest1900, Reliability | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); diff --git a/security_lite/permission_posix/dac/src/ActsDacPreTest.cpp b/security_lite/permission_posix/dac/src/ActsDacPreTest.cpp index a535cb5315087a8c0ba0768ec48e82bbaf488896..0decd13242e83cafb116784e1b17b64e0b5f5e56 100755 --- a/security_lite/permission_posix/dac/src/ActsDacPreTest.cpp +++ b/security_lite/permission_posix/dac/src/ActsDacPreTest.cpp @@ -642,7 +642,7 @@ HWTEST_F(DacTestSuite, DACTest0020, Function | MediumTest | Level1) */ HWTEST_F(DacTestSuite, DACTest0030, Function | MediumTest | Level1) { - int ret; + int ret = 0; gid_t grouplist[SIZE255]; // Preset action: Obtain the groups of the current process unsigned int groupsize = getgroups(0, grouplist); @@ -677,7 +677,7 @@ HWTEST_F(DacTestSuite, DACTest0030, Function | MediumTest | Level1) */ HWTEST_F(DacTestSuite, DACTest0040, Function | MediumTest | Level2) { - int ret; + int ret = 0; gid_t grouplist[SIZE255]; // Preset action: Obtain the groups of the current process unsigned int groupsize = getgroups(0, grouplist); @@ -712,7 +712,7 @@ HWTEST_F(DacTestSuite, DACTest0040, Function | MediumTest | Level2) */ HWTEST_F(DacTestSuite, DACTest0050, Function | MediumTest | Level3) { - int ret; + int ret = 0; gid_t grouplist[SIZE255]; // Preset action: Obtain the groups of the current process unsigned int groupsize = getgroups(0, grouplist); @@ -747,7 +747,7 @@ HWTEST_F(DacTestSuite, DACTest0050, Function | MediumTest | Level3) */ HWTEST_F(DacTestSuite, DACTest0060, Function | MediumTest | Level3) { - int ret; + int ret = 0; gid_t grouplist[SIZE255]; // Preset action: Obtain the groups of the current process size_t groupsize = getgroups(0, grouplist); @@ -787,7 +787,7 @@ HWTEST_F(DacTestSuite, DACTest0060, Function | MediumTest | Level3) */ HWTEST_F(DacTestSuite, DACTest0070, Security | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork three sub processes pid_t pid; @@ -849,7 +849,7 @@ HWTEST_F(DacTestSuite, DACTest0070, Security | MediumTest | Level2) */ HWTEST_F(DacTestSuite, DACTest0080, Function | MediumTest | Level2) { - int ret; + int ret = 0; uid_t ruid = 0; uid_t euid = 0; uid_t suid = 0; uid_t newruid = 0; uid_t neweuid = 0; uid_t newsuid = 0; gid_t rgid = 0; gid_t egid = 0; gid_t sgid = 0; @@ -909,7 +909,7 @@ HWTEST_F(DacTestSuite, DACTest0080, Function | MediumTest | Level2) */ HWTEST_F(DacTestSuite, DACTest0120, Security | MediumTest | Level2) { - int ret; + int ret = 0; int status = 0; // Preset action: Fork a sub process pid_t pid = fork(); diff --git a/security_lite/permission_posix/pms/src/ActsPMSLoadTest.cpp b/security_lite/permission_posix/pms/src/ActsPMSLoadTest.cpp index e3f1c5b7e4d703c50d82090b759114e9ecfe87d4..fb355ebeb53125fc21bae43c9d8c5808e3b20c77 100755 --- a/security_lite/permission_posix/pms/src/ActsPMSLoadTest.cpp +++ b/security_lite/permission_posix/pms/src/ActsPMSLoadTest.cpp @@ -171,7 +171,7 @@ HWTEST_F(ActsPMSLoadTest, testSecPMPMS_0540, Function | MediumTest | Level1) HWTEST_F(ActsPMSLoadTest, testSecPMPMS_0550, Function | MediumTest | Level0) { SaveOrUpdatePermissions(TEST_APP_ID, g_systemPers, SYS_PERM_NUM, FIRST_INSTALL); - int i; + int i = 0; for (i = 0; i < SYS_PERM_NUM; i++) { g_interface->GrantPermission(TEST_APP_ID, g_systemPers[i].name); }