From cc54b4a1220e007026f93158ec1373973d2cd5d5 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 30 Jul 2019 12:51:36 +0200 Subject: [PATCH] =?UTF-8?q?Enforce=C2=A0rule=2015.1=C2=A0of=20the=20High?= =?UTF-8?q?=20Integrity=20C++=20Coding=20Standard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://www.perforce.com/resources/qac/high-integrity-c-coding-standard-exception-handling --- .clang-tidy | 1 + src/algorithms/tracking/libs/tcp_communication.cc | 5 +++-- src/utils/front-end-cal/front_end_cal.cc | 5 +++-- src/utils/front-end-cal/front_end_cal.h | 2 +- src/utils/front-end-cal/main.cc | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 3515d6a2a..33eeda4b4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -12,6 +12,7 @@ Checks: '-*, cppcoreguidelines-slicing, google-build-namespaces, google-runtime-int, + hicpp-exception-baseclass, misc-misplaced-const, misc-new-delete-overloads, misc-non-copyable-objects, diff --git a/src/algorithms/tracking/libs/tcp_communication.cc b/src/algorithms/tracking/libs/tcp_communication.cc index 30809ecc6..f0b191c3e 100644 --- a/src/algorithms/tracking/libs/tcp_communication.cc +++ b/src/algorithms/tracking/libs/tcp_communication.cc @@ -32,6 +32,7 @@ #include "tcp_communication.h" #include "tcp_packet_data.h" #include +#include #include @@ -87,7 +88,7 @@ void Tcp_Communication::send_receive_tcp_packet_galileo_e1(boost::array #include // for operator<< #include +#include #include extern Concurrent_Map global_gps_ephemeris_map; @@ -303,7 +304,7 @@ arma::vec FrontEndCal::geodetic2ecef(double phi, double lambda, double h, const } -double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) +double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false) { int num_secs = 10; double step_secs = 0.5; @@ -359,7 +360,7 @@ double FrontEndCal::estimate_doppler_from_eph(unsigned int PRN, double TOW, doub mean_Doppler_Hz = arma::mean(Doppler_Hz); return mean_Doppler_Hz; } - throw(1); + throw std::runtime_error("1"); } diff --git a/src/utils/front-end-cal/front_end_cal.h b/src/utils/front-end-cal/front_end_cal.h index 07022e505..5f23311b9 100644 --- a/src/utils/front-end-cal/front_end_cal.h +++ b/src/utils/front-end-cal/front_end_cal.h @@ -65,7 +65,7 @@ public: * 3- Approximate receiver Latitude and Longitude (WGS-84) * */ - double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height); + double estimate_doppler_from_eph(unsigned int PRN, double TOW, double lat, double lon, double height) noexcept(false); /*! * \brief This function models the Elonics E4000 + RTL2832 front-end diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index efd752206..935bb4946 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -574,7 +574,7 @@ int main(int argc, char** argv) { std::cout << "Exception caught while reading ephemeris" << std::endl; } - catch (int ex) + catch (const std::exception& ex) { std::cout << " " << it.first << " " << it.second << " (Eph not found)" << std::endl; }