Skip to content

Commit

Permalink
Fix Coverity issues - catch exceptions in tools
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Mar 13, 2024
1 parent f417b81 commit 51b2fc3
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 3 deletions.
10 changes: 10 additions & 0 deletions tools/benchmark/rs-benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,13 @@ catch (const error & e)
cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << endl;
return EXIT_FAILURE;
}
catch( const exception & e )
{
cerr << e.what() << endl;
return EXIT_FAILURE;
}
catch( ... )
{
cerr << "some error" << endl;
return EXIT_FAILURE;
}
10 changes: 10 additions & 0 deletions tools/enumerate-devices/rs-enumerate-devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,3 +713,13 @@ catch (const error & e)
cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << endl;
return EXIT_FAILURE;
}
catch( const exception & e )
{
cerr << e.what() << endl;
return EXIT_FAILURE;
}
catch( ... )
{
cerr << "some error" << endl;
return EXIT_FAILURE;
}
17 changes: 16 additions & 1 deletion tools/fw-logger/rs-fw-logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ string datetime_string()
return string(buffer);
}

int main(int argc, char* argv[])
int main(int argc, char* argv[]) try
{
int default_polling_interval_ms = 100;
CmdLine cmd("librealsense rs-fw-logger example tool", ' ', RS2_API_FULL_VERSION_STR);
Expand Down Expand Up @@ -191,3 +191,18 @@ int main(int argc, char* argv[])

return EXIT_SUCCESS;
}
catch( const rs2::error & e )
{
cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << endl;
return EXIT_FAILURE;
}
catch( const exception & e )
{
cerr << e.what() << endl;
return EXIT_FAILURE;
}
catch( ... )
{
cerr << "some error" << endl;
return EXIT_FAILURE;
}
10 changes: 10 additions & 0 deletions tools/fw-update/rs-fw-update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,3 +606,13 @@ catch (const rs2::error & e)
std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << std::endl;
return EXIT_FAILURE;
}
catch( const std::exception & e )
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cerr << "some error" << std::endl;
return EXIT_FAILURE;
}
12 changes: 11 additions & 1 deletion tools/rosbag-inspector/rs-rosbag-inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ inline void sort(sort_type m_sort_type, const std::string& in, const std::string
}
}

int main(int argc, const char** argv)
int main(int argc, const char** argv) try
{
if (!glfwInit())
{
Expand Down Expand Up @@ -437,6 +437,16 @@ int main(int argc, const char** argv)
glfwTerminate();
return 0;
}
catch( const std::exception & e )
{
std::cerr << e.what() << std::endl;
return EXIT_FAILURE;
}
catch( ... )
{
std::cerr << "some error" << std::endl;
return EXIT_FAILURE;
}

#ifdef WIN32
int CALLBACK WinMain(
Expand Down
17 changes: 16 additions & 1 deletion tools/terminal/rs-terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ rs2::device wait_for_device(const rs2::device_hub& hub, bool print_info = true)
return dev;
}

int main(int argc, char** argv)
int main(int argc, char** argv) try
{
CmdLine cmd("librealsense rs-terminal tool", ' ', RS2_API_FULL_VERSION_STR);
SwitchArg debug_arg( "", "debug", "Turn on LibRS debug logs" );
Expand Down Expand Up @@ -470,3 +470,18 @@ int main(int argc, char** argv)

}
}
catch( const rs2::error & e )
{
cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n " << e.what() << endl;
return EXIT_FAILURE;
}
catch( const exception & e )
{
cerr << e.what() << endl;
return EXIT_FAILURE;
}
catch( ... )
{
cerr << "some error" << endl;
return EXIT_FAILURE;
}

0 comments on commit 51b2fc3

Please sign in to comment.