mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-08 19:56:46 +00:00
Fix const correctness when catching exceptions
See https://stackoverflow.com/questions/7581654/about-catching-exception-good-practices Unneeded includes unistd.h removed Close dump files in destructor
This commit is contained in:
parent
174bba55fc
commit
85cc7802be
@ -447,7 +447,7 @@ bool RtklibPvt::save_assistance_to_XML()
|
||||
ofs.close();
|
||||
LOG(INFO) << "Saved GPS L1 Ephemeris map data";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << e.what();
|
||||
return false;
|
||||
|
@ -335,7 +335,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
msgctl(sysv_msqid, IPC_RMID, NULL);
|
||||
|
||||
//save GPS L2CM ephemeris to XML file
|
||||
std::string file_name="eph_GPS_L2CM.xml";
|
||||
std::string file_name = "eph_GPS_L2CM.xml";
|
||||
|
||||
if (d_ls_pvt->gps_cnav_ephemeris_map.size() > 0)
|
||||
{
|
||||
@ -347,7 +347,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
ofs.close();
|
||||
LOG(INFO) << "Saved GPS L2CM Ephemeris map data";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << e.what();
|
||||
}
|
||||
@ -370,7 +370,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
ofs.close();
|
||||
LOG(INFO) << "Saved GPS L1 CA Ephemeris map data";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << e.what();
|
||||
}
|
||||
@ -393,7 +393,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
ofs.close();
|
||||
LOG(INFO) << "Saved Galileo E1 Ephemeris map data";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << e.what();
|
||||
}
|
||||
@ -403,6 +403,17 @@ rtklib_pvt_cc::~rtklib_pvt_cc()
|
||||
LOG(WARNING) << "Failed to save Galileo E1 Ephemeris, map is empty";
|
||||
}
|
||||
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,7 +69,17 @@ hybrid_ls_pvt::hybrid_ls_pvt(int nchannels, std::string dump_filename, bool flag
|
||||
|
||||
hybrid_ls_pvt::~hybrid_ls_pvt()
|
||||
{
|
||||
d_dump_file.close();
|
||||
if (d_dump_file.is_open() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
d_dump_file.close();
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -167,7 +167,7 @@ bool Nmea_Printer::Print_Nmea_Line(const std::shared_ptr<Pvt_Solution>& pvt_data
|
||||
//GPGSV
|
||||
nmea_file_descriptor << GPGSV;
|
||||
}
|
||||
catch(std::exception ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
DLOG(INFO) << "NMEA printer can not write on output file" << nmea_filename.c_str();;
|
||||
}
|
||||
|
@ -364,6 +364,7 @@ int Pvt_Solution::tropo(double *ddr_m, double sinel, double hsta_km, double p_mb
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Pvt_Solution::topocent(double *Az, double *El, double *D, const arma::vec & x, const arma::vec & dx)
|
||||
{
|
||||
/* Transformation of vector dx into topocentric coordinate
|
||||
@ -474,7 +475,7 @@ int Pvt_Solution::compute_DOP()
|
||||
d_VDOP = sqrt(DOP_ENU(2, 2)); // VDOP
|
||||
d_TDOP = sqrt(d_Q(3, 3)); // TDOP
|
||||
}
|
||||
catch(std::exception& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
d_GDOP = -1; // Geometric DOP
|
||||
d_PDOP = -1; // PDOP
|
||||
@ -483,12 +484,9 @@ int Pvt_Solution::compute_DOP()
|
||||
d_TDOP = -1; // TDOP
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int Pvt_Solution::set_averaging_depth(int depth)
|
||||
{
|
||||
d_averaging_depth = depth;
|
||||
|
@ -131,11 +131,11 @@ Rtcm_Printer::~Rtcm_Printer()
|
||||
{
|
||||
rtcm->stop_server();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -305,9 +305,9 @@ bool Rtcm_Printer::Print_Message(const std::string & message)
|
||||
{
|
||||
rtcm_file_descriptor << message << std::endl;
|
||||
}
|
||||
catch(std::exception ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
DLOG(INFO) << "RTCM printer can not write on output file" << rtcm_filename.c_str();
|
||||
DLOG(INFO) << "RTCM printer cannot write on the output file " << rtcm_filename.c_str();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -316,8 +316,8 @@ bool Rtcm_Printer::Print_Message(const std::string & message)
|
||||
{
|
||||
if(write(rtcm_dev_descriptor, message.c_str(), message.length()) == -1)
|
||||
{
|
||||
DLOG(INFO) << "RTCM printer cannot write on serial device" << rtcm_devname.c_str();
|
||||
std::cout << "RTCM printer cannot write on serial device" << rtcm_devname.c_str() << std::endl;
|
||||
DLOG(INFO) << "RTCM printer cannot write on serial device " << rtcm_devname.c_str();
|
||||
std::cout << "RTCM printer cannot write on serial device " << rtcm_devname.c_str() << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -94,4 +94,3 @@ channel_msg_receiver_cc::channel_msg_receiver_cc(ChannelFsm* channel_fsm, bool r
|
||||
|
||||
channel_msg_receiver_cc::~channel_msg_receiver_cc()
|
||||
{}
|
||||
|
||||
|
@ -79,12 +79,12 @@ OsmosdrSignalSource::OsmosdrSignalSource(ConfigurationInterface* configuration,
|
||||
{
|
||||
if (!osmosdr_args_.empty())
|
||||
{
|
||||
std::cout << "OsmoSdr arguments: " << osmosdr_args_ << std::endl;
|
||||
LOG(INFO) << "OsmoSdr arguments: " << osmosdr_args_;
|
||||
std::cout << "OsmoSdr arguments: " << osmosdr_args_ << std::endl;
|
||||
LOG(INFO) << "OsmoSdr arguments: " << osmosdr_args_;
|
||||
}
|
||||
osmosdr_source_ = osmosdr::source::make(osmosdr_args_);
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration,
|
||||
LOG (INFO) << "Connecting to " << address_ << ":" << port_;
|
||||
signal_source_ = rtl_tcp_make_signal_source_c (address_, port_, flip_iq_);
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ int tcp_communication::listen_tcp_connection(size_t d_port_, size_t d_port_ch0_)
|
||||
std::cout << "Socket accepted on port " << d_port_ << std::endl;
|
||||
}
|
||||
|
||||
catch(std::exception& e)
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << std::endl;
|
||||
}
|
||||
@ -102,7 +102,7 @@ void tcp_communication::send_receive_tcp_packet_galileo_e1(boost::array<float, N
|
||||
tcp_data_->proc_pack_carrier_doppler_hz = readbuf.data()[3];
|
||||
}
|
||||
|
||||
catch(std::exception& e)
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << ". Please press Ctrl+C to end the program." << std::endl;
|
||||
std::cin >> controlc;
|
||||
@ -137,7 +137,7 @@ void tcp_communication::send_receive_tcp_packet_gps_l1_ca(boost::array<float, NU
|
||||
tcp_data_->proc_pack_carrier_doppler_hz = readbuf.data()[3];
|
||||
}
|
||||
|
||||
catch(std::exception& e)
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << ". Please press Ctrl+C to end the program." << std::endl;
|
||||
std::cin >> controlc;
|
||||
|
@ -33,7 +33,6 @@
|
||||
*/
|
||||
|
||||
#include "control_thread.h"
|
||||
#include <unistd.h>
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
@ -33,8 +33,6 @@
|
||||
*/
|
||||
|
||||
#include "gnss_flowgraph.h"
|
||||
#include "unistd.h"
|
||||
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
@ -80,7 +78,7 @@ void GNSSFlowgraph::start()
|
||||
{
|
||||
top_block_->start();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Unable to start flowgraph";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -123,7 +121,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
sig_source_.at(i)->connect(top_block_);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(INFO) << "Can't connect signal source block " << i << " internally";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -139,7 +137,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
sig_conditioner_.at(i)->connect(top_block_);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(INFO) << "Can't connect signal conditioner block " << i << " internally";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -154,7 +152,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
channels_.at(i)->connect(top_block_);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect channel " << i << " internally";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -167,7 +165,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
observables_->connect(top_block_);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect observables block internally";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -180,7 +178,7 @@ void GNSSFlowgraph::connect()
|
||||
{
|
||||
pvt_->connect(top_block_);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect PVT block internally";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -248,7 +246,7 @@ void GNSSFlowgraph::connect()
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect signal source " << i << " to signal conditioner " << i;
|
||||
LOG(ERROR) << e.what();
|
||||
@ -268,7 +266,7 @@ void GNSSFlowgraph::connect()
|
||||
top_block_->connect(sig_conditioner_.at(selected_signal_conditioner_ID)->get_right_block(), 0,
|
||||
channels_.at(i)->get_left_block(), 0);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect signal conditioner " << selected_signal_conditioner_ID << " to channel " << i;
|
||||
LOG(ERROR) << e.what();
|
||||
@ -284,7 +282,7 @@ void GNSSFlowgraph::connect()
|
||||
top_block_->connect(channels_.at(i)->get_right_block(), 0,
|
||||
observables_->get_left_block(), i);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect channel " << i << " to observables";
|
||||
LOG(ERROR) << e.what();
|
||||
@ -331,7 +329,7 @@ void GNSSFlowgraph::connect()
|
||||
top_block_->msg_connect(channels_.at(i)->get_right_block(), pmt::mp("telemetry"), pvt_->get_left_block(), pmt::mp("telemetry"));
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Can't connect observables to PVT";
|
||||
LOG(ERROR) << e.what();
|
||||
|
@ -65,11 +65,11 @@ Rtcm::~Rtcm()
|
||||
{
|
||||
stop_server();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
LOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(WARNING) << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -95,7 +95,7 @@ void Rtcm::run_server()
|
||||
server_is_running = true;
|
||||
t.detach();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
std::cerr << "Exception: " << e.what() << "\n";
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ int main(int argc, char** argv)
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
if (FLAGS_log_dir.empty())
|
||||
{
|
||||
std::cout << "Logging will be done at "
|
||||
std::cout << "Logging will be written at "
|
||||
<< boost::filesystem::temp_directory_path()
|
||||
<< std::endl
|
||||
<< "Use gnss-sdr --log_dir=/path/to/log to change that."
|
||||
@ -124,7 +124,7 @@ int main(int argc, char** argv)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
std::cout << "Logging with be done at " << FLAGS_log_dir << std::endl;
|
||||
std::cout << "Logging will be written at " << FLAGS_log_dir << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,11 +138,11 @@ int main(int argc, char** argv)
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
LOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
LOG(FATAL) << "STD exception: " << ex.what();
|
||||
}
|
||||
|
@ -329,11 +329,11 @@ int ObsGpsL1SystemTest::run_receiver()
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -413,12 +413,12 @@ void ObsGpsL1SystemTest::check_results()
|
||||
} // end for
|
||||
} // end while
|
||||
} // End of 'try' block
|
||||
catch(gpstk::FFStreamError& e)
|
||||
catch(const gpstk::FFStreamError& e)
|
||||
{
|
||||
std::cout << e;
|
||||
exit(1);
|
||||
}
|
||||
catch(gpstk::Exception& e)
|
||||
catch(const gpstk::Exception& e)
|
||||
{
|
||||
std::cout << e;
|
||||
exit(1);
|
||||
@ -473,12 +473,12 @@ void ObsGpsL1SystemTest::check_results()
|
||||
} // end for
|
||||
} // end while
|
||||
} // End of 'try' block
|
||||
catch(gpstk::FFStreamError& e)
|
||||
catch(const gpstk::FFStreamError& e)
|
||||
{
|
||||
std::cout << e;
|
||||
exit(1);
|
||||
}
|
||||
catch(gpstk::Exception& e)
|
||||
catch(const gpstk::Exception& e)
|
||||
{
|
||||
std::cout << e;
|
||||
exit(1);
|
||||
|
@ -417,11 +417,11 @@ int StaticPositionSystemTest::run_receiver()
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
|
@ -489,11 +489,11 @@ TEST_F(TfttGpsL1CATest, ColdStart)
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -572,11 +572,11 @@ TEST_F(TfttGpsL1CATest, HotStart)
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ TEST_F(ControlThreadTest, InstantiateRunControlMessages)
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -193,11 +193,11 @@ TEST_F(ControlThreadTest, InstantiateRunControlMessages2)
|
||||
{
|
||||
control_thread2->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
@ -249,11 +249,11 @@ TEST_F(ControlThreadTest, StopReceiverProgrammatically)
|
||||
{
|
||||
control_thread->run();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch(const boost::exception & e)
|
||||
{
|
||||
std::cout << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
catch(std::exception const& ex)
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
std::cout << "STD exception: " << ex.what();
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test::wait_message()
|
||||
{
|
||||
channel_internal_queue.wait_and_pop(message);
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
DLOG(FATAL) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoCTest::wait_message()
|
||||
channel_internal_queue.wait_and_pop(message);
|
||||
stop_queue();
|
||||
}
|
||||
catch( boost::exception & e )
|
||||
catch( const boost::exception & e )
|
||||
{
|
||||
DLOG(WARNING) << "Boost exception: " << boost::diagnostic_information(e);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ TEST(RtcmPrinterTest, Run)
|
||||
// xml >> boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", gps_ephemeris_map);
|
||||
// ifs.close();
|
||||
// }
|
||||
// catch (std::exception& e)
|
||||
// catch (const std::exception& e)
|
||||
// {
|
||||
// //LOG(WARNING) << e.what() << "File: " << file_name;
|
||||
// //std::cout << "File not found" << std::endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user