diff --git a/.clang-tidy b/.clang-tidy index d71c07a3b..bcc3e3cdb 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: '-*,boost-use-to-string,cert-dcl21-cpp,cert-dcl58-cpp,cert-env33-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,clang-analyzer-cplusplus*,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-build-namespaces,google-runtime-int,google-runtime-references,misc-misplaced-const,misc-new-delete-overloads,misc-non-copyable-objects,misc-static-assert,misc-throw-by-value-catch-by-reference,misc-uniqueptr-reset-release,modernize-loop-convert,modernize-pass-by-value,modernize-raw-string-literal,modernize-use-auto,modernize-use-bool-literals,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,performance-faster-string-find,performance-inefficient-algorithm,performance-move-const-arg,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,readability-container-size-empty,readability-named-parameter,readability-non-const-parameter,readability-string-compare' +Checks: '-*,boost-use-to-string,cert-dcl21-cpp,cert-dcl58-cpp,cert-env33-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,clang-analyzer-cplusplus*,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-build-namespaces,google-runtime-int,misc-misplaced-const,misc-new-delete-overloads,misc-non-copyable-objects,misc-static-assert,misc-throw-by-value-catch-by-reference,misc-uniqueptr-reset-release,modernize-loop-convert,modernize-pass-by-value,modernize-raw-string-literal,modernize-use-auto,modernize-use-bool-literals,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,performance-faster-string-find,performance-inefficient-algorithm,performance-move-const-arg,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,readability-container-size-empty,readability-named-parameter,readability-non-const-parameter,readability-string-compare' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false @@ -21,8 +21,6 @@ CheckOptions: value: '_t' - key: google-runtime-int.UnsignedTypePrefix value: uint - - key: google-runtime-references.WhiteListTypes - value: '' - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries value: '1' - key: modernize-loop-convert.MaxCopySize diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 151c667c8..e618e7b5d 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -618,7 +618,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << e.what(); } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -704,7 +704,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -734,7 +734,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << e.what(); } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -764,7 +764,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -794,7 +794,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -824,7 +824,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -854,7 +854,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -914,7 +914,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -944,7 +944,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -974,7 +974,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -1004,7 +1004,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -1064,7 +1064,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -1124,7 +1124,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); } @@ -1176,7 +1176,7 @@ bool rtklib_pvt_cc::save_gnss_synchro_map_xml(const std::string& file_name) xml << boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map); LOG(INFO) << "Saved gnss_sychro map data"; } - catch (std::exception& e) + catch (const std::exception& e) { LOG(WARNING) << e.what(); return false; @@ -1201,7 +1201,7 @@ bool rtklib_pvt_cc::load_gnss_synchro_map_xml(const std::string& file_name) xml >> boost::serialization::make_nvp("GNSS-SDR_gnss_synchro_map", gnss_observables_map); //std::cout << "Loaded gnss_synchro map data with " << gnss_synchro_map.size() << " pseudoranges" << std::endl; } - catch (std::exception& e) + catch (const std::exception& e) { std::cout << e.what() << "File: " << file_name; return false; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index aeabc0517..0a9115622 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -93,11 +93,11 @@ rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag { try { - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.exceptions(std::ofstream::failbit | std::ofstream::badbit); d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "PVT lib dump enabled Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure &e) + catch (const std::ofstream::failure &e) { LOG(WARNING) << "Exception opening RTKLIB dump file " << e.what(); } diff --git a/src/core/receiver/control_message_factory.cc b/src/core/receiver/control_message_factory.cc index d2871d39e..435a9a6d6 100644 --- a/src/core/receiver/control_message_factory.cc +++ b/src/core/receiver/control_message_factory.cc @@ -53,7 +53,7 @@ gr::message::sptr ControlMessageFactory::GetQueueMessage(unsigned int who, unsig } -std::shared_ptr>> ControlMessageFactory::GetControlMessages(const gr::message::sptr& queue_message) +std::shared_ptr>> ControlMessageFactory::GetControlMessages(const gr::message::sptr queue_message) // NOLINT(performance-unnecessary-value-param) { std::shared_ptr>> control_messages = std::make_shared>>(); unsigned int control_messages_count = queue_message->length() / sizeof(ControlMessage); diff --git a/src/core/receiver/control_message_factory.h b/src/core/receiver/control_message_factory.h index 3aac015a9..4ca93e725 100644 --- a/src/core/receiver/control_message_factory.h +++ b/src/core/receiver/control_message_factory.h @@ -58,7 +58,7 @@ public: virtual ~ControlMessageFactory(); gr::message::sptr GetQueueMessage(unsigned int who, unsigned int what); - std::shared_ptr>> GetControlMessages(const gr::message::sptr& queue_message); + std::shared_ptr>> GetControlMessages(const gr::message::sptr queue_message); // NOLINT(performance-unnecessary-value-param) }; #endif /*GNSS_SDR_CONTROL_MESSAGE_FACTORY_H_*/ diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 71e789778..6bb4f7b9d 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -285,11 +285,16 @@ int ControlThread::run() flowgraph_->disconnect(); // Join keyboard thread - keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); - - LOG(INFO) << "Flowgraph stopped"; + try + { + keyboard_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + sysv_queue_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + cmd_interface_thread_.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(1000)); + } + catch (const boost::thread_interrupted &interrupt) + { + DLOG(INFO) << "Thread interrupted"; + } if (restart_) { @@ -300,7 +305,7 @@ int ControlThread::run() } -void ControlThread::set_control_queue(const gr::msg_queue::sptr &control_queue) +void ControlThread::set_control_queue(const gr::msg_queue::sptr control_queue) // NOLINT(performance-unnecessary-value-param) { if (flowgraph_->running()) { diff --git a/src/core/receiver/control_thread.h b/src/core/receiver/control_thread.h index b500e43fa..590ebb622 100644 --- a/src/core/receiver/control_thread.h +++ b/src/core/receiver/control_thread.h @@ -93,7 +93,7 @@ public: * * \param[in] boost::shared_ptr control_queue */ - void set_control_queue(const gr::msg_queue::sptr& control_queue); + void set_control_queue(const gr::msg_queue::sptr control_queue); // NOLINT(performance-unnecessary-value-param) unsigned int processed_control_messages() diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index e0e08a8c0..dce01a732 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -182,7 +182,7 @@ GNSSBlockFactory::~GNSSBlockFactory() = default; std::unique_ptr GNSSBlockFactory::GetSignalSource( - const std::shared_ptr& configuration, const gr::msg_queue::sptr& queue, int ID) + const std::shared_ptr& configuration, const gr::msg_queue::sptr queue, int ID) // NOLINT(performance-unnecessary-value-param) { std::string default_implementation = "File_Signal_Source"; std::string role = "SignalSource"; //backwards compatibility for old conf files @@ -851,7 +851,7 @@ std::unique_ptr GNSSBlockFactory::GetChannel_B1( } std::unique_ptr>> GNSSBlockFactory::GetChannels( - const std::shared_ptr& configuration, const gr::msg_queue::sptr& queue) + const std::shared_ptr& configuration, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { std::string default_implementation = "Pass_Through"; std::string tracking_implementation; @@ -1139,7 +1139,7 @@ std::unique_ptr GNSSBlockFactory::GetBlock( const std::shared_ptr& configuration, const std::string& role, const std::string& implementation, unsigned int in_streams, - unsigned int out_streams, const gr::msg_queue::sptr& queue) + unsigned int out_streams, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { std::unique_ptr block; diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index e3eb02226..d9c153794 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -58,7 +58,7 @@ public: GNSSBlockFactory(); virtual ~GNSSBlockFactory(); std::unique_ptr GetSignalSource(const std::shared_ptr& configuration, - const gr::msg_queue::sptr& queue, int ID = -1); + const gr::msg_queue::sptr queue, int ID = -1); // NOLINT(performance-unnecessary-value-param) std::unique_ptr GetSignalConditioner(const std::shared_ptr& configuration, int ID = -1); @@ -67,7 +67,7 @@ public: std::unique_ptr GetObservables(const std::shared_ptr& configuration); std::unique_ptr>> GetChannels(const std::shared_ptr& configuration, - const gr::msg_queue::sptr& queue); + const gr::msg_queue::sptr queue); // NOLINT(performance-unnecessary-value-param) /* * \brief Returns the block with the required configuration and implementation @@ -75,7 +75,7 @@ public: std::unique_ptr GetBlock(const std::shared_ptr& configuration, const std::string& role, const std::string& implementation, unsigned int in_streams, unsigned int out_streams, - const gr::msg_queue::sptr& queue = nullptr); + const gr::msg_queue::sptr queue = nullptr); // NOLINT(performance-unnecessary-value-param) private: std::unique_ptr GetChannel_1C(const std::shared_ptr& configuration, diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index 82cc49e09..be8b18f01 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -62,7 +62,7 @@ using google::LogMessage; -GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr& queue) +GNSSFlowgraph::GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr queue) // NOLINT(performance-unnecessary-value-param) { connected_ = false; running_ = false; @@ -839,6 +839,7 @@ void GNSSFlowgraph::disconnect() for (unsigned int i = 0; i < channels_count_; i++) { top_block_->disconnect(observables_->get_right_block(), i, pvt_->get_left_block(), i); + top_block_->disconnect(observables_->get_right_block(), i, GnssSynchroMonitor_, i); top_block_->msg_disconnect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry")); } } diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 67f86bc6b..e0023b444 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -72,7 +72,7 @@ public: /*! * \brief Constructor that initializes the receiver flow graph */ - GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr& queue); + GNSSFlowgraph(std::shared_ptr configuration, const gr::msg_queue::sptr queue); // NOLINT(performance-unnecessary-value-param) /*! * \brief Destructor