Skip to content

Commit

Permalink
Fix static analysis issues (#79)
Browse files Browse the repository at this point in the history
Signed-off-by: Jemale Lockett <jemale.lockett@intel.com>
  • Loading branch information
Jemale authored Oct 1, 2024
1 parent f62bdc4 commit e0bae5a
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 7 deletions.
3 changes: 3 additions & 0 deletions conformance_tests/core/test_ipc/src/test_ipc_multidevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ int main(int argc, char **argv) {
} catch (const std::exception &e) {
LOG_ERROR << "Failed to init google mock: " << e.what();
return 1;
} catch (...) {
LOG_ERROR << "Failed to init google mock with unknown exception";
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ int main(int argc, char **argv) {
} catch (std::exception &e) {
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "Failed to initialize GoogleMock" << std::endl;
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
Expand Down
10 changes: 9 additions & 1 deletion conformance_tests/core/test_ipc/src/test_ipc_p2p_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,15 @@ INSTANTIATE_TEST_SUITE_P(
// zeInit should be handled with fork(), so each process must call
// zeInit
int main(int argc, char **argv) {
::testing::InitGoogleMock(&argc, argv);
try {
::testing::InitGoogleMock(&argc, argv);
} catch (std::exception &e) {
std::cerr << "Failed to init Google Mock: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "Failed to init Google Mock: unknown exception" << std::endl;
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);

Expand Down
3 changes: 3 additions & 0 deletions conformance_tests/core/test_ipc/src/test_ipc_put_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ int main(int argc, char **argv) {
} catch (std::exception &e) {
std::cerr << "Failed to initialize GoogleMock: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "Failed to initialize GoogleMock" << std::endl;
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
Expand Down
6 changes: 5 additions & 1 deletion perf_tests/cl_image_copy/src/cl_image_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,11 @@ void measure_latency(ClImageCopyLatency &imageCopyLatency) {
ptree ptree_param_array;

if (imageCopyLatency.is_json_output_enabled()) {
pt::read_json(imageCopyLatency.JsonFileName, ptree_main);
try {
pt::read_json(imageCopyLatency.JsonFileName, ptree_main);
} catch (const std::exception &e) {
std::cerr << "Error reading json file:" << e.what() << std::endl;
}
}
measure_latency_Host2Device(imageCopyLatency, &ptree_Host2Device);
measure_latency_Device2Host(imageCopyLatency, &ptree_Device2Host);
Expand Down
8 changes: 7 additions & 1 deletion stress_tests/test_memory_allocation/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ int main(int argc, char **argv) {
LOG_TRACE << "Driver initialized";
level_zero_tests::print_platform_overview();

return RUN_ALL_TESTS();
try {
auto result = RUN_ALL_TESTS();
return result;
} catch (const std::exception &e) {
LOG_ERROR << "Error: " << e.what();
return 1;
}
}
3 changes: 3 additions & 0 deletions stress_tests/test_misc/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ int main(int argc, char **argv) {
} catch (const std::exception &e) {
LOG_ERROR << "Failed to init google mock: " << e.what();
return 1;
} catch (...) {
LOG_ERROR << "Failed to init google mock";
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
Expand Down
7 changes: 5 additions & 2 deletions utils/logging/src/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@ void init_logging(const LoggingSettings settings) {

void init_logging(std::vector<std::string> &command_line) {
try {
init_logging(parse_command_line(command_line));
init_logging(parse_command_line(command_line));
} catch (const boost::bad_lexical_cast &e) {
std::cerr << "Error initializing logging parsing command line: " << e.what() << std::endl;
std::cerr << "Error initializing logging parsing command line: " << e.what()
<< std::endl;
} catch (std::exception &e) {
std::cerr << "Error initializing logging: " << e.what() << std::endl;
}
}

Expand Down
9 changes: 8 additions & 1 deletion utils/random/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,12 @@ int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
return RUN_ALL_TESTS();

try {
auto result = RUN_ALL_TESTS();
return result;
} catch (std::exception &e) {
LOG_ERROR << "Error: " << e.what();
return 1;
}
}
6 changes: 5 additions & 1 deletion utils/test_harness/src/test_harness_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,11 @@ zeEventPool::~zeEventPool() {
if (event_pool_) {
auto result = zeEventPoolDestroy(event_pool_);
if (ZE_RESULT_SUCCESS != result) {
LOG_ERROR << "Failed to destroy event pool: " << result;
try {
LOG_ERROR << "Failed to destroy event pool: " << result;
} catch (...) {
// Do nothing
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions utils/utils/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ int main(int argc, char **argv) {
} catch (std::exception &e) {
std::cerr << "Test failed with exception: " << e.what() << std::endl;
return 1;
} catch (...) {
std::cerr << "Test failed with unknown exception" << std::endl;
return 1;
}
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);
Expand Down

0 comments on commit e0bae5a

Please sign in to comment.