Skip to content

Commit e0bae5a

Browse files
authored
Fix static analysis issues (#79)
Signed-off-by: Jemale Lockett <[email protected]>
1 parent f62bdc4 commit e0bae5a

File tree

11 files changed

+54
-7
lines changed

11 files changed

+54
-7
lines changed

conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ int main(int argc, char **argv) {
262262
} catch (const std::exception &e) {
263263
LOG_ERROR << "Failed to init google mock: " << e.what();
264264
return 1;
265+
} catch (...) {
266+
LOG_ERROR << "Failed to init google mock with unknown exception";
267+
return 1;
265268
}
266269
std::vector<std::string> command_line(argv + 1, argv + argc);
267270
level_zero_tests::init_logging(command_line);

conformance_tests/core/test_ipc/src/test_ipc_multisubdevice.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ int main(int argc, char **argv) {
297297
} catch (std::exception &e) {
298298
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
299299
return 1;
300+
} catch (...) {
301+
std::cerr << "Failed to initialize GoogleMock" << std::endl;
302+
return 1;
300303
}
301304
std::vector<std::string> command_line(argv + 1, argv + argc);
302305
level_zero_tests::init_logging(command_line);

conformance_tests/core/test_ipc/src/test_ipc_p2p_memory.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,15 @@ INSTANTIATE_TEST_SUITE_P(
479479
// zeInit should be handled with fork(), so each process must call
480480
// zeInit
481481
int main(int argc, char **argv) {
482-
::testing::InitGoogleMock(&argc, argv);
482+
try {
483+
::testing::InitGoogleMock(&argc, argv);
484+
} catch (std::exception &e) {
485+
std::cerr << "Failed to init Google Mock: " << e.what() << std::endl;
486+
return 1;
487+
} catch (...) {
488+
std::cerr << "Failed to init Google Mock: unknown exception" << std::endl;
489+
return 1;
490+
}
483491
std::vector<std::string> command_line(argv + 1, argv + argc);
484492
level_zero_tests::init_logging(command_line);
485493

conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ int main(int argc, char **argv) {
541541
} catch (std::exception &e) {
542542
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
543543
return 1;
544+
} catch (...) {
545+
std::cerr << "Failed to initialize GoogleMock" << std::endl;
546+
return 1;
544547
}
545548
std::vector<std::string> command_line(argv + 1, argv + argc);
546549
level_zero_tests::init_logging(command_line);

perf_tests/cl_image_copy/src/cl_image_copy.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,11 @@ void measure_latency(ClImageCopyLatency &imageCopyLatency) {
583583
ptree ptree_param_array;
584584

585585
if (imageCopyLatency.is_json_output_enabled()) {
586-
pt::read_json(imageCopyLatency.JsonFileName, ptree_main);
586+
try {
587+
pt::read_json(imageCopyLatency.JsonFileName, ptree_main);
588+
} catch (const std::exception &e) {
589+
std::cerr << "Error reading json file:" << e.what() << std::endl;
590+
}
587591
}
588592
measure_latency_Host2Device(imageCopyLatency, &ptree_Host2Device);
589593
measure_latency_Device2Host(imageCopyLatency, &ptree_Device2Host);

stress_tests/test_memory_allocation/src/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ int main(int argc, char **argv) {
2323
LOG_TRACE << "Driver initialized";
2424
level_zero_tests::print_platform_overview();
2525

26-
return RUN_ALL_TESTS();
26+
try {
27+
auto result = RUN_ALL_TESTS();
28+
return result;
29+
} catch (const std::exception &e) {
30+
LOG_ERROR << "Error: " << e.what();
31+
return 1;
32+
}
2733
}

stress_tests/test_misc/src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ int main(int argc, char **argv) {
7171
} catch (const std::exception &e) {
7272
LOG_ERROR << "Failed to init google mock: " << e.what();
7373
return 1;
74+
} catch (...) {
75+
LOG_ERROR << "Failed to init google mock";
76+
return 1;
7477
}
7578
std::vector<std::string> command_line(argv + 1, argv + argc);
7679
level_zero_tests::init_logging(command_line);

utils/logging/src/logging.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ void init_logging(const LoggingSettings settings) {
6464

6565
void init_logging(std::vector<std::string> &command_line) {
6666
try {
67-
init_logging(parse_command_line(command_line));
67+
init_logging(parse_command_line(command_line));
6868
} catch (const boost::bad_lexical_cast &e) {
69-
std::cerr << "Error initializing logging parsing command line: " << e.what() << std::endl;
69+
std::cerr << "Error initializing logging parsing command line: " << e.what()
70+
<< std::endl;
71+
} catch (std::exception &e) {
72+
std::cerr << "Error initializing logging: " << e.what() << std::endl;
7073
}
7174
}
7275

utils/random/test/main.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,12 @@ int main(int argc, char **argv) {
1313
::testing::InitGoogleTest(&argc, argv);
1414
std::vector<std::string> command_line(argv + 1, argv + argc);
1515
level_zero_tests::init_logging(command_line);
16-
return RUN_ALL_TESTS();
16+
17+
try {
18+
auto result = RUN_ALL_TESTS();
19+
return result;
20+
} catch (std::exception &e) {
21+
LOG_ERROR << "Error: " << e.what();
22+
return 1;
23+
}
1724
}

utils/test_harness/src/test_harness_event.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ zeEventPool::~zeEventPool() {
282282
if (event_pool_) {
283283
auto result = zeEventPoolDestroy(event_pool_);
284284
if (ZE_RESULT_SUCCESS != result) {
285-
LOG_ERROR << "Failed to destroy event pool: " << result;
285+
try {
286+
LOG_ERROR << "Failed to destroy event pool: " << result;
287+
} catch (...) {
288+
// Do nothing
289+
}
286290
}
287291
}
288292
}

0 commit comments

Comments
 (0)