Skip to content

Commit 44aa65a

Browse files
authored
Merge pull request #1535 from bratpiorka/rrudnick_coverity_fix
coverity fixes
2 parents 10b0aec + b87c93d commit 44aa65a

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

examples/ctl/ctl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,6 @@ static bool report_pool_stat_failure(const char *label,
6666
reason = "slab statistics";
6767
} else if (hint_level == 2) {
6868
reason = "allocation counters";
69-
} else if (hint_level < 3) {
70-
hint_level = 2;
71-
reason = "allocation counters";
7269
} else {
7370
hint_level = 3;
7471
}

test/common/level_zero_mocks.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ TestCreateMemoryAllocationProperties(uint32_t modifier) {
9999
void MockedLevelZeroTestEnvironment::SetUp() {
100100
const char *lib_name = getenv("UMF_ZE_LOADER_LIB_NAME");
101101
ASSERT_NE(lib_name, nullptr);
102+
if (lib_name == nullptr) {
103+
return; // to avoid nullptr deref coverity issue
104+
}
102105
ASSERT_NE(lib_name[0], '\0');
103106

104107
lib_handle = utils_open_library(lib_name, 0);

test/pools/pool_residency.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,12 @@ TEST_F(PoolResidencyTestFixture,
176176
}
177177

178178
int main(int argc, char **argv) {
179-
InitGoogleTest(&argc, argv);
180-
AddGlobalTestEnvironment(new MockedLevelZeroTestEnvironment);
181-
return RUN_ALL_TESTS();
179+
try {
180+
InitGoogleTest(&argc, argv);
181+
AddGlobalTestEnvironment(new MockedLevelZeroTestEnvironment);
182+
return RUN_ALL_TESTS();
183+
} catch (...) {
184+
std::cerr << "Exception occurred." << std::endl;
185+
return 1;
186+
}
182187
}

test/providers/provider_level_zero_residency.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ TEST_F(LevelZeroResidencyTestFixture, removeDeviceTwiceShouldFail) {
8383
}
8484

8585
int main(int argc, char **argv) {
86-
InitGoogleTest(&argc, argv);
87-
AddGlobalTestEnvironment(new MockedLevelZeroTestEnvironment);
88-
return RUN_ALL_TESTS();
86+
try {
87+
InitGoogleTest(&argc, argv);
88+
AddGlobalTestEnvironment(new MockedLevelZeroTestEnvironment);
89+
return RUN_ALL_TESTS();
90+
} catch (...) {
91+
std::cerr << "Exception occurred." << std::endl;
92+
return 1;
93+
}
8994
}

0 commit comments

Comments
 (0)