From 7261bec2ad7ffdeea1d53adda86a481a3e89dfba Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 4 Dec 2018 13:20:49 +0100 Subject: [PATCH 1/6] Miscelaneous code improvements --- .../galileo_e1_pcps_ambiguous_acquisition.cc | 2 +- .../adapters/glonass_l1_ca_pcps_acquisition.cc | 2 +- .../adapters/glonass_l2_ca_pcps_acquisition.cc | 2 +- .../adapters/gps_l1_ca_pcps_acquisition.cc | 2 +- .../adapters/gps_l2_m_pcps_acquisition.cc | 2 +- .../adapters/gps_l5i_pcps_acquisition.cc | 2 +- .../gnuradio_blocks/pcps_acquisition.cc | 5 +---- .../input_filter/adapters/fir_filter.cc | 4 ++-- .../adapters/freq_xlating_fir_filter.cc | 4 ++-- .../adapters/pulse_blanking_filter.cc | 7 ++----- src/algorithms/libs/gnss_sdr_flags.cc | 8 ++++---- src/algorithms/libs/pass_through.cc | 4 ++-- .../gnuradio_blocks/hybrid_observables_cc.cc | 15 ++++----------- .../glonass_l1_ca_dll_pll_c_aid_tracking.cc | 16 ++++++---------- .../glonass_l2_ca_dll_pll_c_aid_tracking.cc | 14 ++++---------- .../adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc | 14 ++++---------- .../system_parameters/galileo_fnav_message.cc | 6 +----- .../galileo_navigation_message.cc | 6 +----- .../glonass_gnav_navigation_message.cc | 8 +++----- .../gps_cnav_navigation_message.cc | 6 +----- src/utils/front-end-cal/front_end_cal.cc | 5 +---- 21 files changed, 44 insertions(+), 90 deletions(-) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 22262ca2b..150dffb27 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -338,7 +338,7 @@ gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc index 9f9cb22d6..a3cf3d0e0 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -323,7 +323,7 @@ gr::basic_block_sptr GlonassL1CaPcpsAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc index ef6a7dcf1..4227ad9f8 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -322,7 +322,7 @@ gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index 2af325c52..c0462f703 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -311,7 +311,7 @@ gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc index acf415635..f64515302 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -325,7 +325,7 @@ gr::basic_block_sptr GpsL2MPcpsAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index 16066ebaa..a01644c64 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -313,7 +313,7 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_left_block() { return acquisition_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return cbyte_to_float_x2_; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 224a873e6..5510c4d7f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -274,10 +274,7 @@ bool pcps_acquisition::is_fdma() LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << d_old_freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; return true; } - else - { - return false; - } + return false; } diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc index b09ab9af0..097ac7a22 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.cc +++ b/src/algorithms/input_filter/adapters/fir_filter.cc @@ -287,7 +287,7 @@ gr::basic_block_sptr FirFilter::get_left_block() { return cshort_to_float_x2_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { return cbyte_to_float_x2_; } @@ -317,7 +317,7 @@ gr::basic_block_sptr FirFilter::get_right_block() { return short_x2_to_cshort_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "gr_complex")) { return float_to_complex_; } diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index f430edbfd..c0c92c884 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -327,7 +327,7 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_left_block() { return freq_xlating_fir_filter_fcf_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } @@ -361,7 +361,7 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_right_block() { return freq_xlating_fir_filter_fcf_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } diff --git a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc index 236ecd4cc..ccf6704cc 100644 --- a/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc +++ b/src/algorithms/input_filter/adapters/pulse_blanking_filter.cc @@ -160,11 +160,8 @@ gr::basic_block_sptr PulseBlankingFilter::get_left_block() } return pulse_blanking_cc_; } - else - { - LOG(ERROR) << " Unknown input filter input/output item type conversion"; - return nullptr; - } + LOG(ERROR) << " Unknown input filter input/output item type conversion"; + return nullptr; } diff --git a/src/algorithms/libs/gnss_sdr_flags.cc b/src/algorithms/libs/gnss_sdr_flags.cc index a43351916..3eba67822 100644 --- a/src/algorithms/libs/gnss_sdr_flags.cc +++ b/src/algorithms/libs/gnss_sdr_flags.cc @@ -69,7 +69,7 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter, static bool ValidateC(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok + if (boost::filesystem::exists(value) or value == "-") // value is ok return true; std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; @@ -78,7 +78,7 @@ static bool ValidateC(const char* flagname, const std::string& value) static bool ValidateConfigFile(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare(std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) == 0) // value is ok + if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) // value is ok return true; std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; @@ -87,7 +87,7 @@ static bool ValidateConfigFile(const char* flagname, const std::string& value) static bool ValidateS(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok + if (boost::filesystem::exists(value) or value == "-") // value is ok return true; std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; @@ -96,7 +96,7 @@ static bool ValidateS(const char* flagname, const std::string& value) static bool ValidateSignalSource(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value.compare("-") == 0) // value is ok + if (boost::filesystem::exists(value) or value == "-") // value is ok return true; std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index b388363da..731fa6ba7 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -153,7 +153,7 @@ gr::basic_block_sptr Pass_Through::get_left_block() { return conjugate_sc_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return conjugate_ic_; } @@ -180,7 +180,7 @@ gr::basic_block_sptr Pass_Through::get_right_block() { return conjugate_sc_; } - else if (item_type_ == "cbyte") + if (item_type_ == "cbyte") { return conjugate_ic_; } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index d2d6edd2d..685c28c49 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -411,18 +411,11 @@ bool hybrid_observables_cc::interp_trk_obs(Gnss_Synchro &interpolated_obs, const } return false; } - else - { - // std::cout << "ALERT: Channel " << ch << " interp buff idx " << nearest_element - // << " ,diff: " << old_abs_diff << " samples (" << static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs) << " s)\n"; - // usleep(1000); - return false; - } - } - else - { - return false; + // std::cout << "ALERT: Channel " << ch << " interp buff idx " << nearest_element + // << " ,diff: " << old_abs_diff << " samples (" << static_cast(old_abs_diff) / static_cast(d_gnss_synchro_history->at(ch, nearest_element).fs) << " s)\n"; + // usleep(1000); } + return false; } diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc index a285dc0b0..d72de6894 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc @@ -224,11 +224,8 @@ gr::basic_block_sptr GlonassL1CaDllPllCAidTracking::get_left_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } @@ -242,9 +239,8 @@ gr::basic_block_sptr GlonassL1CaDllPllCAidTracking::get_right_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + + + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc index c23cc3263..346f89778 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc @@ -222,11 +222,8 @@ gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_left_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } @@ -240,9 +237,6 @@ gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_right_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc index 0b8366d4a..899e878e2 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc @@ -218,11 +218,8 @@ gr::basic_block_sptr GpsL1CaDllPllCAidTracking::get_left_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } gr::basic_block_sptr GpsL1CaDllPllCAidTracking::get_right_block() @@ -235,9 +232,6 @@ gr::basic_block_sptr GpsL1CaDllPllCAidTracking::get_right_block() { return tracking_sc; } - else - { - LOG(WARNING) << item_type_ << " unknown tracking item type"; - return nullptr; - } + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; } diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index 58888effe..913b18461 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -496,12 +496,8 @@ bool Galileo_Fnav_Message::have_new_ephemeris() // Check if we have a new ephem std::cout << "Batch number: " << IOD_ephemeris << std::endl; return true; } - return false; - } - else - { - return false; } + return false; } diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index 8407cf3e6..51c28068d 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -439,12 +439,8 @@ bool Galileo_Navigation_Message::have_new_ephemeris() // Check if we have a new std::cout << "Batch number: " << IOD_ephemeris << std::endl; return true; } - - - return false; } - else - return false; + return false; } diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index b360a5c02..b2a825894 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -204,11 +204,9 @@ bool Glonass_Gnav_Navigation_Message::CRC_test(std::bitset Date: Fri, 7 Dec 2018 21:00:30 +0100 Subject: [PATCH 2/6] Use nullptr --- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 4 +- src/algorithms/libs/rtklib/rtklib_rtksvr.cc | 28 ++++----- src/algorithms/libs/rtklib/rtklib_stream.cc | 70 ++++++++++----------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 2ac962251..a62d649d0 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -3635,7 +3635,7 @@ double satwavelen(int sat, int frq, const nav_t *nav) return SPEED_OF_LIGHT / FREQ1_BDS; /* B1 */ if (frq == 1) return SPEED_OF_LIGHT / FREQ2_BDS; /* B2 */ - else if (frq == 2) + if (frq == 2) return SPEED_OF_LIGHT / FREQ3_BDS; /* B3 */ } else @@ -3644,7 +3644,7 @@ double satwavelen(int sat, int frq, const nav_t *nav) return SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ if (frq == 1) return SPEED_OF_LIGHT / FREQ2; /* L2 */ - else if (frq == 2) + if (frq == 2) return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ else if (frq == 3) return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 4687d73d2..3fafef550 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -129,7 +129,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, for (i = 0; i < obs->n; i++) { if (svr->rtk.opt.exsats[obs->data[i].sat - 1] == 1 || - !(satsys(obs->data[i].sat, NULL) & svr->rtk.opt.navsys)) continue; + !(satsys(obs->data[i].sat, nullptr) & svr->rtk.opt.navsys)) continue; svr->obs[index][iobs].data[n] = obs->data[i]; svr->obs[index][iobs].data[n++].rcv = index + 1; } @@ -291,7 +291,7 @@ int decoderaw(rtksvr_t *svr, int index) { obs_t *obs; nav_t *nav; - sbsmsg_t *sbsmsg = NULL; + sbsmsg_t *sbsmsg = nullptr; int i, ret = 0, sat, fobs = 0; tracet(4, "decoderaw: index=%d\n", index); @@ -373,8 +373,8 @@ void decodefile(rtksvr_t *svr, int index) trop_t trop0[MAXSTA] = {{{0, 0.0}, {0.0}, {0.0}}}; pppcorr_t pppcorr0 = {0, {{0}, {0}}, {{0.0}, {0.0}}, {0}, {0}, {0}, {0}, {stec0}, {trop0}}; - nav_t nav = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - {0, 0, (erpd_t *){0}}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, + nav_t nav = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, + {0, 0, (erpd_t *){nullptr}}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, {0.0}, 0, {{0.0}, {0.0}}, {{0.0}, {0.0}}, {{{0.0}}, {{0.0}}, {{0.0}}}, {0.0}, {0.0}, {*glo_fcn}, {*pcvt0}, sbssat0, {*sbsion0}, {*dgps0}, {*ssr0}, {*lexeph0}, {{0, 0.0}, 0.0, {0.0}, {{0.0}, {0.0}}}, pppcorr0}; @@ -564,9 +564,9 @@ void *rtksvrthread(void *arg) { svr->nb[i] = svr->npb[i] = 0; free(svr->buff[i]); - svr->buff[i] = NULL; + svr->buff[i] = nullptr; free(svr->pbuf[i]); - svr->pbuf[i] = NULL; + svr->pbuf[i] = nullptr; //free_raw (svr->raw +i); free_rtcm(svr->rtcm + i); } @@ -574,9 +574,9 @@ void *rtksvrthread(void *arg) { svr->nsb[i] = 0; free(svr->sbuf[i]); - svr->sbuf[i] = NULL; + svr->sbuf[i] = nullptr; } - return 0; + return nullptr; } @@ -610,15 +610,15 @@ int rtksvrinit(rtksvr_t *svr) for (i = 0; i < 3; i++) svr->nb[i] = 0; for (i = 0; i < 2; i++) svr->nsb[i] = 0; for (i = 0; i < 3; i++) svr->npb[i] = 0; - for (i = 0; i < 3; i++) svr->buff[i] = NULL; - for (i = 0; i < 2; i++) svr->sbuf[i] = NULL; - for (i = 0; i < 3; i++) svr->pbuf[i] = NULL; + for (i = 0; i < 3; i++) svr->buff[i] = nullptr; + for (i = 0; i < 2; i++) svr->sbuf[i] = nullptr; + for (i = 0; i < 3; i++) svr->pbuf[i] = nullptr; for (i = 0; i < MAXSOLBUF; i++) svr->solbuf[i] = sol0; for (i = 0; i < 3; i++) for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; for (i = 0; i < 3; i++) svr->ftime[i] = time0; for (i = 0; i < 3; i++) svr->files[i][0] = '\0'; - svr->moni = NULL; + svr->moni = nullptr; svr->tick = 0; svr->thread = 0; svr->cputime = svr->prcout = 0; @@ -840,7 +840,7 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, writesolhead(svr->stream + i, svr->solopt + i - 3); } /* create rtk server thread */ - if (pthread_create(&svr->thread, NULL, rtksvrthread, svr)) + if (pthread_create(&svr->thread, nullptr, rtksvrthread, svr)) { for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream + i); return 0; @@ -876,7 +876,7 @@ void rtksvrstop(rtksvr_t *svr, char **cmds) svr->state = 0; /* free rtk server thread */ - pthread_join(svr->thread, NULL); + pthread_join(svr->thread, nullptr); } diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 59b833c5b..6e50d2f8f 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -94,7 +94,7 @@ serial_t *openserial(const char *path, int mode, char *msg) int rw = 0; tracet(3, "openserial: path=%s mode=%d\n", path, mode); - if (!(serial = (serial_t *)malloc(sizeof(serial_t)))) return NULL; + if (!(serial = (serial_t *)malloc(sizeof(serial_t)))) return nullptr; if ((p = strchr((char *)path, ':'))) { @@ -112,7 +112,7 @@ serial_t *openserial(const char *path, int mode, char *msg) sprintf(msg, "bitrate error (%d)", brate); tracet(1, "openserial: %s path=%s\n", msg, path); free(serial); - return NULL; + return nullptr; } parity = (char)toupper((int)parity); @@ -135,7 +135,7 @@ serial_t *openserial(const char *path, int mode, char *msg) sprintf(msg, "device open error (%d)", errno); tracet(1, "openserial: %s dev=%s\n", msg, dev); free(serial); - return NULL; + return nullptr; } tcgetattr(serial->dev, &ios); ios.c_iflag = 0; @@ -295,7 +295,7 @@ void closefile_(file_t *file) if (file->fp_tag) fclose(file->fp_tag); if (file->fp_tmp) fclose(file->fp_tmp); if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = NULL; + file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -310,7 +310,7 @@ file_t *openfile(const char *path, int mode, char *msg) tracet(3, "openfile: path=%s mode=%d\n", path, mode); - if (!(mode & (STR_MODE_R | STR_MODE_W))) return NULL; + if (!(mode & (STR_MODE_R | STR_MODE_W))) return nullptr; /* file options */ for (p = (char *)path; (p = strstr(p, "::")); p += 2) @@ -327,9 +327,9 @@ file_t *openfile(const char *path, int mode, char *msg) if (start <= 0.0) start = 0.0; if (swapintv <= 0.0) swapintv = 0.0; - if (!(file = (file_t *)malloc(sizeof(file_t)))) return NULL; + if (!(file = (file_t *)malloc(sizeof(file_t)))) return nullptr; - file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = NULL; + file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; if (strlen(path) < MAXSTRPATH) strcpy(file->path, path); if ((p = strstr(file->path, "::"))) *p = '\0'; file->openpath[0] = '\0'; @@ -350,7 +350,7 @@ file_t *openfile(const char *path, int mode, char *msg) if (!openfile_(file, time, msg)) { free(file); - return NULL; + return nullptr; } return file; } @@ -399,7 +399,7 @@ void swapclose(file_t *file) tracet(3, "swapclose: fp_tmp=%d\n", file->fp_tmp); if (file->fp_tmp) fclose(file->fp_tmp); if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); - file->fp_tmp = file->fp_tag_tmp = NULL; + file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -427,7 +427,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) /* input from stdin */ FD_ZERO(&rs); FD_SET(0, &rs); - if (!select(1, &rs, NULL, NULL, &tv)) return 0; + if (!select(1, &rs, nullptr, nullptr, &tv)) return 0; if ((nr = read(0, buff, nmax)) < 0) return 0; return nr; } @@ -652,7 +652,7 @@ socket_t accept_nb(socket_t sock, struct sockaddr *addr, socklen_t *len) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, NULL, NULL, &tv)) return 0; + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0; return accept(sock, addr, len); } @@ -673,7 +673,7 @@ int connect_nb(socket_t sock, struct sockaddr *addr, socklen_t len) FD_ZERO(&rs); FD_SET(sock, &rs); ws = rs; - if (select(sock + 1, &rs, &ws, NULL, &tv) == 0) return 0; + if (select(sock + 1, &rs, &ws, nullptr, &tv) == 0) return 0; } return 1; } @@ -686,7 +686,7 @@ int recv_nb(socket_t sock, unsigned char *buff, int n) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, NULL, NULL, &tv)) return 0; + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0; return recv(sock, (char *)buff, n, 0); } @@ -698,7 +698,7 @@ int send_nb(socket_t sock, unsigned char *buff, int n) fd_set ws; FD_ZERO(&ws); FD_SET(sock, &ws); - if (!select(sock + 1, NULL, &ws, NULL, &tv)) return 0; + if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) return 0; return send(sock, (char *)buff, n, 0); } @@ -788,20 +788,20 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg) tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}}; tracet(3, "opentcpsvr: path=%s\n", path); - if (!(tcpsvr = (tcpsvr_t *)malloc(sizeof(tcpsvr_t)))) return NULL; + if (!(tcpsvr = (tcpsvr_t *)malloc(sizeof(tcpsvr_t)))) return nullptr; *tcpsvr = tcpsvr0; - decodetcppath(path, tcpsvr->svr.saddr, port, NULL, NULL, NULL, NULL); + decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) { sprintf(msg, "port error: %s", port); tracet(1, "opentcpsvr: port error port=%s\n", port); free(tcpsvr); - return NULL; + return nullptr; } if (!gentcp(&tcpsvr->svr, 0, msg)) { free(tcpsvr); - return NULL; + return nullptr; } tcpsvr->svr.tcon = 0; return tcpsvr; @@ -1018,15 +1018,15 @@ tcpcli_t *opentcpcli(const char *path, char *msg) tracet(3, "opentcpcli: path=%s\n", path); - if (!(tcpcli = (tcpcli_t *)malloc(sizeof(tcpcli_t)))) return NULL; + if (!(tcpcli = (tcpcli_t *)malloc(sizeof(tcpcli_t)))) return nullptr; *tcpcli = tcpcli0; - decodetcppath(path, tcpcli->svr.saddr, port, NULL, NULL, NULL, NULL); + decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpcli->svr.port) < 1) { sprintf(msg, "port error: %s", port); tracet(1, "opentcp: port error port=%s\n", port); free(tcpcli); - return NULL; + return nullptr; } tcpcli->svr.tcon = 0; tcpcli->toinact = toinact; @@ -1367,7 +1367,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg) tracet(3, "openntrip: path=%s type=%d\n", path, type); - if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return NULL; + if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return nullptr; ntrip->state = 0; ntrip->type = type; /* 0:server, 1:client */ @@ -1402,7 +1402,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg) { tracet(1, "openntrip: opentcp error\n"); free(ntrip); - return NULL; + return nullptr; } return ntrip; } @@ -1548,7 +1548,7 @@ void *ftpthread(void *arg) tracet(1, "no local directory\n"); ftp->error = 11; ftp->state = 3; - return 0; + return nullptr; } /* replace keyword in file path and local path */ time = timeadd(utc2gpst(timeget()), ftp->topts[0]); @@ -1584,7 +1584,7 @@ void *ftpthread(void *arg) strcpy(ftp->local, tmpfile); tracet(3, "ftpthread: file exists %s\n", ftp->local); ftp->state = 2; - return 0; + return nullptr; } /* proxy settings for wget (ref [2]) */ if (*proxyaddr) @@ -1633,7 +1633,7 @@ void *ftpthread(void *arg) tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd, ret); ftp->error = ret; ftp->state = 3; - return 0; + return nullptr; } if (remove(errfile) != 0) trace(1, "Error removing file"); @@ -1652,14 +1652,14 @@ void *ftpthread(void *arg) tracet(1, "file uncompact error: %s\n", local); ftp->error = 12; ftp->state = 3; - return 0; + return nullptr; } } if (strlen(local) < 1024) strcpy(ftp->local, local); ftp->state = 2; /* ftp completed */ tracet(3, "ftpthread: complete cmd=%s\n", cmd); - return 0; + return nullptr; } @@ -1672,7 +1672,7 @@ ftp_t *openftp(const char *path, int type, char *msg) msg[0] = '\0'; - if (!(ftp = (ftp_t *)malloc(sizeof(ftp_t)))) return NULL; + if (!(ftp = (ftp_t *)malloc(sizeof(ftp_t)))) return nullptr; ftp->state = 0; ftp->proto = type; @@ -1718,7 +1718,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) ftp->state = 1; sprintf(msg, "%s://%s", ftp->proto ? "http" : "ftp", ftp->addr); - if (pthread_create(&ftp->thread, NULL, ftpthread, ftp)) + if (pthread_create(&ftp->thread, nullptr, ftpthread, ftp)) { tracet(1, "readftp: ftp thread create error\n"); ftp->state = 3; @@ -1786,7 +1786,7 @@ void strinit(stream_t *stream) stream->inb = stream->inr = stream->outb = stream->outr = 0; stream->tick = stream->tact = stream->inbt = stream->outbt = 0; initlock(&stream->lock); - stream->port = NULL; + stream->port = nullptr; stream->path[0] = '\0'; stream->msg[0] = '\0'; } @@ -1838,7 +1838,7 @@ int stropen(stream_t *stream, int type, int mode, const char *path) stream->tick = tickget(); stream->inbt = stream->outbt = 0; stream->msg[0] = '\0'; - stream->port = NULL; + stream->port = nullptr; switch (type) { case STR_SERIAL: @@ -1870,7 +1870,7 @@ int stropen(stream_t *stream, int type, int mode, const char *path) return 1; } stream->state = !stream->port ? -1 : 1; - return stream->port != NULL; + return stream->port != nullptr; } @@ -1923,7 +1923,7 @@ void strclose(stream_t *stream) stream->inr = stream->outr = 0; stream->path[0] = '\0'; stream->msg[0] = '\0'; - stream->port = NULL; + stream->port = nullptr; } @@ -2286,7 +2286,7 @@ int gen_hex(const char *msg, unsigned char *buff) trace(4, "gen_hex: msg=%s\n", msg); strncpy(mbuff, msg, 1023); - for (p = strtok(mbuff, " "); p && narg < 256; p = strtok(NULL, " ")) + for (p = strtok(mbuff, " "); p && narg < 256; p = strtok(nullptr, " ")) { args[narg++] = p; } From 17260bbceadd7e2d3ad09aaa2680e121c3f3f971 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 8 Dec 2018 18:49:31 +0100 Subject: [PATCH 3/6] Miscelaneous code improvements by clang-tidy --- src/algorithms/PVT/adapters/rtklib_pvt.h | 2 +- .../PVT/gnuradio_blocks/rtklib_pvt_cc.cc | 2 +- src/algorithms/PVT/libs/rtcm_printer.cc | 15 +- src/algorithms/PVT/libs/rtklib_solver.cc | 9 +- .../galileo_e1_pcps_ambiguous_acquisition.cc | 8 +- .../glonass_l1_ca_pcps_acquisition.cc | 8 +- .../glonass_l2_ca_pcps_acquisition.cc | 8 +- .../adapters/gps_l1_ca_pcps_acquisition.cc | 8 +- .../adapters/gps_l2_m_pcps_acquisition.cc | 8 +- .../adapters/gps_l5i_pcps_acquisition.cc | 8 +- .../galileo_pcps_8ms_acquisition_cc.cc | 41 ++-- .../galileo_pcps_8ms_acquisition_cc.h | 83 +++++--- .../pcps_assisted_acquisition_cc.cc | 32 +-- .../pcps_assisted_acquisition_cc.h | 69 ++++--- .../pcps_cccwsr_acquisition_cc.cc | 50 +++-- .../pcps_cccwsr_acquisition_cc.h | 67 +++--- .../pcps_quicksync_acquisition_cc.cc | 57 ++--- .../pcps_quicksync_acquisition_cc.h | 74 +++---- .../pcps_tong_acquisition_cc.cc | 54 ++--- .../pcps_tong_acquisition_cc.h | 80 ++++---- .../adapters/byte_to_short.cc | 4 +- .../input_filter/adapters/fir_filter.cc | 8 +- .../adapters/freq_xlating_fir_filter.cc | 8 +- .../gnuradio_blocks/beamformer.cc | 2 +- .../libs/galileo_e5_signal_processing.cc | 2 +- src/algorithms/libs/gnss_sdr_valve.cc | 8 +- src/algorithms/libs/gnss_sdr_valve.h | 15 +- src/algorithms/libs/pass_through.cc | 14 +- src/algorithms/libs/rtklib/rtklib.h | 1 + src/algorithms/libs/rtklib/rtklib_ionex.cc | 18 +- src/algorithms/libs/rtklib/rtklib_lambda.cc | 6 +- src/algorithms/libs/rtklib/rtklib_pntpos.cc | 12 +- src/algorithms/libs/rtklib/rtklib_ppp.cc | 12 +- src/algorithms/libs/rtklib/rtklib_preceph.cc | 26 +-- src/algorithms/libs/rtklib/rtklib_rtcm.cc | 12 +- src/algorithms/libs/rtklib/rtklib_rtcm3.cc | 48 ++--- src/algorithms/libs/rtklib/rtklib_rtkcmn.cc | 174 ++++++++-------- src/algorithms/libs/rtklib/rtklib_rtkpos.cc | 34 +-- src/algorithms/libs/rtklib/rtklib_rtksvr.cc | 30 +-- src/algorithms/libs/rtklib/rtklib_sbas.cc | 56 ++--- src/algorithms/libs/rtklib/rtklib_solution.cc | 154 +++++++------- src/algorithms/libs/rtklib/rtklib_stream.cc | 194 +++++++++--------- src/algorithms/libs/short_x2_to_cshort.cc | 12 +- .../gnuradio_blocks/hybrid_observables_cc.cc | 2 +- .../adapters/direct_resampler_conditioner.cc | 3 +- .../adapters/signal_generator.cc | 8 +- .../adapters/labsat_signal_source.cc | 4 +- .../adapters/rtl_tcp_signal_source.cc | 7 +- .../two_bit_packed_file_signal_source.cc | 2 +- .../gnuradio_blocks/labsat23_source.cc | 189 +++++++++-------- .../rtl_tcp_signal_source_c.cc | 4 +- .../gnuradio_blocks/rtl_tcp_signal_source_c.h | 7 +- .../gnuradio_blocks/unpack_2bit_samples.cc | 6 +- .../unpack_byte_2bit_cpx_samples.cc | 31 +-- .../unpack_byte_2bit_samples.cc | 2 +- .../signal_source/libs/rtl_tcp_dongle_info.h | 2 +- .../galileo_telemetry_decoder_cc.cc | 2 +- .../galileo_telemetry_decoder_cc.h | 2 +- .../glonass_l1_ca_telemetry_decoder_cc.cc | 4 +- .../glonass_l1_ca_telemetry_decoder_cc.h | 2 +- .../glonass_l2_ca_telemetry_decoder_cc.cc | 4 +- .../glonass_l2_ca_telemetry_decoder_cc.h | 2 +- .../gps_l1_ca_telemetry_decoder_cc.cc | 4 +- .../gps_l1_ca_telemetry_decoder_cc.h | 2 +- .../gps_l2c_telemetry_decoder_cc.cc | 2 +- .../gps_l2c_telemetry_decoder_cc.h | 2 +- .../gps_l5_telemetry_decoder_cc.cc | 2 +- .../gps_l5_telemetry_decoder_cc.h | 4 +- .../sbas_l1_telemetry_decoder_cc.cc | 2 +- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 2 +- ...glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc | 8 +- ...glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 8 +- ...glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc | 8 +- ...glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 8 +- .../gps_l1_ca_dll_pll_c_aid_tracking_cc.cc | 8 +- .../gps_l1_ca_dll_pll_c_aid_tracking_sc.cc | 8 +- .../gps_l1_ca_kf_tracking_cc.cc | 2 +- src/algorithms/tracking/libs/dll_pll_conf.h | 2 +- .../tracking/libs/tcp_communication.cc | 4 +- .../tracking/libs/tracking_loop_filter.cc | 17 +- src/core/libs/INIReader.cc | 10 +- src/core/libs/INIReader.h | 4 +- src/core/libs/gnss_sdr_supl_client.h | 4 +- src/core/libs/string_converter.cc | 6 +- .../libs/supl/asn-rrlp/converter-sample.c | 2 +- src/core/libs/supl/asn-rrlp/per_encoder.c | 2 +- src/core/libs/supl/asn-rrlp/per_opentype.c | 2 +- src/core/libs/supl/asn-supl/per_encoder.c | 2 +- src/core/libs/supl/asn-supl/per_opentype.c | 2 +- src/core/libs/supl/supl.c | 2 +- src/core/monitor/gnss_synchro_udp_sink.cc | 2 +- src/core/monitor/gnss_synchro_udp_sink.h | 2 +- src/core/system_parameters/rtcm.cc | 6 +- src/tests/system-tests/position_test.cc | 8 +- src/tests/system-tests/ttff.cc | 4 +- .../gps_l1_ca_pcps_acquisition_test.cc | 4 +- .../adapter/adapter_test.cc | 28 +-- .../galileo_e1_dll_pll_veml_tracking_test.cc | 2 +- src/utils/front-end-cal/front_end_cal.cc | 14 +- src/utils/front-end-cal/main.cc | 14 +- 100 files changed, 1039 insertions(+), 990 deletions(-) diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.h b/src/algorithms/PVT/adapters/rtklib_pvt.h index d222ce565..41235471b 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.h +++ b/src/algorithms/PVT/adapters/rtklib_pvt.h @@ -94,7 +94,7 @@ public: private: rtklib_pvt_cc_sptr pvt_; - rtk_t rtk; + rtk_t rtk{}; std::string role_; unsigned int in_streams_; unsigned int out_streams_; diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 4a52770c9..87ea980b1 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -514,7 +514,7 @@ rtklib_pvt_cc::rtklib_pvt_cc(uint32_t nchannels, if ((sysv_msqid = msgget(sysv_msg_key, msgflg)) == -1) { std::cout << "GNSS-SDR can not create message queues!" << std::endl; - throw new std::exception(); + throw std::exception(); } start = std::chrono::system_clock::now(); } diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index 89fd17b46..3cfe7faaa 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -37,6 +37,7 @@ #include // for path, operator<< #include // for filesystem #include +#include #include #include #include // for O_RDWR @@ -187,7 +188,7 @@ Rtcm_Printer::~Rtcm_Printer() } if (rtcm_file_descriptor.is_open()) { - long pos; + int64_t pos; pos = rtcm_file_descriptor.tellp(); rtcm_file_descriptor.close(); if (pos == 0) @@ -345,13 +346,13 @@ int Rtcm_Printer::init_serial(const std::string& serial_device) */ int32_t fd = 0; struct termios options; - long BAUD; - long DATABITS; - long STOPBITS; - long PARITYON; - long PARITY; + int64_t BAUD; + int64_t DATABITS; + int64_t STOPBITS; + int64_t PARITYON; + int64_t PARITY; - fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY); + fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); if (fd == -1) return fd; // failed to open TTY port if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 4e00c5621..86719aa5d 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -59,7 +59,6 @@ #include "GLONASS_L1_L2_CA.h" #include #include - #include @@ -75,10 +74,10 @@ rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag count_valid_position = 0; this->set_averaging_flag(false); rtk_ = rtk; - for (double & i : dop_) i = 0.0; + for (double &i : dop_) i = 0.0; pvt_sol = {{0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, '0', '0', '0', 0, 0, 0}; ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}}; - for (auto & i : pvt_ssat) + for (auto &i : pvt_ssat) { i = ssat0; } @@ -777,7 +776,7 @@ bool rtklib_solver::get_PVT(const std::map &gnss_observables_ nav_data.n = valid_obs; nav_data.ng = glo_valid_obs; - for (auto & i : nav_data.lam) + for (auto &i : nav_data.lam) { i[0] = SPEED_OF_LIGHT / FREQ1; // L1/E1 i[1] = SPEED_OF_LIGHT / FREQ2; // L2 @@ -811,7 +810,7 @@ bool rtklib_solver::get_PVT(const std::map &gnss_observables_ std::vector azel; azel.reserve(used_sats * 2); unsigned int index_aux = 0; - for (auto & i : rtk_.ssat) + for (auto &i : rtk_.ssat) { if (i.vs == 1) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 150dffb27..0384ce949 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -342,11 +342,9 @@ gr::basic_block_sptr GalileoE1PcpsAmbiguousAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc index a3cf3d0e0..0bb8cc9e4 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -327,11 +327,9 @@ gr::basic_block_sptr GlonassL1CaPcpsAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc index 4227ad9f8..4c9fd6440 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -326,11 +326,9 @@ gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index c0462f703..e631d17eb 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -315,11 +315,9 @@ gr::basic_block_sptr GpsL1CaPcpsAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc index f64515302..bc293524a 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -329,11 +329,9 @@ gr::basic_block_sptr GpsL2MPcpsAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index a01644c64..f3f8cf2a9 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -317,11 +317,9 @@ gr::basic_block_sptr GpsL5iPcpsAcquisition::get_left_block() { return cbyte_to_float_x2_; } - else - { - LOG(WARNING) << item_type_ << " unknown acquisition item type"; - return nullptr; - } + + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index eaf7ff134..879746959 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -41,9 +41,12 @@ using google::LogMessage; galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) { return galileo_pcps_8ms_acquisition_cc_sptr( @@ -52,9 +55,12 @@ galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( } galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) : gr::block("galileo_pcps_8ms_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), @@ -101,11 +107,12 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( d_channel = 0; } + galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -125,6 +132,7 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() } } + void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) { // code A: two replicas of a primary code @@ -146,6 +154,7 @@ void galileo_pcps_8ms_acquisition_cc::set_local_code(std::complex *code) volk_32fc_conjugate_32fc(d_fft_code_B, d_fft_if->get_outbuf(), d_fft_size); } + void galileo_pcps_8ms_acquisition_cc::init() { d_gnss_synchro->Flag_valid_acquisition = false; @@ -161,8 +170,8 @@ void galileo_pcps_8ms_acquisition_cc::init() const double GALILEO_TWO_PI = 6.283185307179600; // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -170,10 +179,10 @@ void galileo_pcps_8ms_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; float phase_step_rad = static_cast(GALILEO_TWO_PI) * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; @@ -182,7 +191,7 @@ void galileo_pcps_8ms_acquisition_cc::init() } -void galileo_pcps_8ms_acquisition_cc::set_state(int state) +void galileo_pcps_8ms_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) @@ -210,7 +219,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -240,7 +249,7 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; uint32_t indext_A = 0; uint32_t indext_B = 0; @@ -268,10 +277,10 @@ int galileo_pcps_8ms_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h index dc00681a3..11f6eadca 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h @@ -44,10 +44,14 @@ class galileo_pcps_8ms_acquisition_cc; typedef boost::shared_ptr galileo_pcps_8ms_acquisition_cc_sptr; galileo_pcps_8ms_acquisition_cc_sptr -galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); +galileo_pcps_8ms_make_acquisition_cc(uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition for @@ -57,41 +61,52 @@ class galileo_pcps_8ms_acquisition_cc : public gr::block { private: friend galileo_pcps_8ms_acquisition_cc_sptr - galileo_pcps_8ms_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); + galileo_pcps_8ms_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); + galileo_pcps_8ms_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); - galileo_pcps_8ms_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); + void calculate_magnitudes( + gr_complex* fft_begin, + int32_t doppler_shift, + int32_t doppler_offset); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); - - long d_fs_in; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_code_A; gr_complex* d_fft_code_B; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -99,9 +114,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -123,7 +138,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -154,13 +169,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -179,7 +194,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -188,7 +203,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index 43850040b..5ce6fb232 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -47,8 +47,8 @@ extern concurrent_map global_gps_acq_assist_map; using google::LogMessage; pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, - long fs_in, int samples_per_ms, bool dump, + int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, + int64_t fs_in, int32_t samples_per_ms, bool dump, std::string dump_filename) { return pcps_assisted_acquisition_cc_sptr( @@ -58,8 +58,8 @@ pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( - int max_dwells, unsigned int sampled_ms, int doppler_max, int doppler_min, - long fs_in, int samples_per_ms, bool dump, + int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, + int64_t fs_in, int32_t samples_per_ms, bool dump, std::string dump_filename) : gr::block("pcps_assisted_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(0, 0, sizeof(gr_complex))) @@ -109,7 +109,7 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( } -void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step) +void pcps_assisted_acquisition_cc::set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } @@ -117,7 +117,7 @@ void pcps_assisted_acquisition_cc::set_doppler_step(unsigned int doppler_step) void pcps_assisted_acquisition_cc::free_grid_memory() { - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { delete[] d_grid_data[i]; delete[] d_grid_doppler_wipeoffs[i]; @@ -206,9 +206,9 @@ void pcps_assisted_acquisition_cc::get_assistance() void pcps_assisted_acquisition_cc::reset_grid() { d_well_count = 0; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { - for (unsigned int j = 0; j < d_fft_size; j++) + for (uint32_t j = 0; j < d_fft_size; j++) { d_grid_data[i][j] = 0.0; } @@ -227,16 +227,16 @@ void pcps_assisted_acquisition_cc::redefine_grid() d_num_doppler_points = floor(std::abs(d_doppler_max - d_doppler_min) / d_doppler_step); d_grid_data = new float *[d_num_doppler_points]; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { d_grid_data[i] = new float[d_fft_size]; } // create the carrier Doppler wipeoff signals - int doppler_hz; + int32_t doppler_hz; float phase_step_rad; d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_points]; - for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) + for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { doppler_hz = d_doppler_min + d_doppler_step * doppler_index; // doppler search steps @@ -254,11 +254,11 @@ double pcps_assisted_acquisition_cc::search_maximum() { float magt = 0.0; float fft_normalization_factor; - int index_doppler = 0; + int32_t index_doppler = 0; uint32_t tmp_intex_t = 0; uint32_t index_time = 0; - for (int i = 0; i < d_num_doppler_points; i++) + for (int32_t i = 0; i < d_num_doppler_points; i++) { volk_gnsssdr_32f_index_max_32u(&tmp_intex_t, d_grid_data[i], d_fft_size); if (d_grid_data[i][tmp_intex_t] > magt) @@ -316,7 +316,7 @@ float pcps_assisted_acquisition_cc::estimate_input_power(gr_vector_const_void_st } -int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items) +int32_t pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_void_star &input_items) { // initialize acquisition algorithm const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer @@ -331,7 +331,7 @@ int pcps_assisted_acquisition_cc::compute_and_accumulate_grid(gr_vector_const_vo // 2- Doppler frequency search loop auto *p_tmp_vector = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - for (int doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) + for (int32_t doppler_index = 0; doppler_index < d_num_doppler_points; doppler_index++) { // doppler search steps // Perform the carrier wipe-off @@ -394,7 +394,7 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, d_state = 2; break; case 2: // S2. ComputeGrid - int consumed_samples; + int32_t consumed_samples; consumed_samples = compute_and_accumulate_grid(input_items); d_well_count++; if (d_well_count >= d_max_dwells) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h index 70b73f715..e8d093061 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h @@ -61,8 +61,13 @@ typedef boost::shared_ptr pcps_assisted_acquisition_cc_sptr; pcps_assisted_acquisition_cc_sptr -pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long fs_in, int samples_per_ms, +pcps_make_assisted_acquisition_cc( + int32_t max_dwells, + uint32_t sampled_ms, + int32_t doppler_max, + int32_t doppler_min, + int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); /*! @@ -75,20 +80,20 @@ class pcps_assisted_acquisition_cc : public gr::block { private: friend pcps_assisted_acquisition_cc_sptr - pcps_make_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long fs_in, - int samples_per_ms, bool dump, + pcps_make_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, + int32_t doppler_max, int32_t doppler_min, int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); - pcps_assisted_acquisition_cc(int max_dwells, unsigned int sampled_ms, - int doppler_max, int doppler_min, long fs_in, - int samples_per_ms, bool dump, + pcps_assisted_acquisition_cc(int32_t max_dwells, uint32_t sampled_ms, + int32_t doppler_max, int32_t doppler_min, int64_t fs_in, + int32_t samples_per_ms, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - int compute_and_accumulate_grid(gr_vector_const_void_star& input_items); + int32_t compute_and_accumulate_grid(gr_vector_const_void_star& input_items); float estimate_input_power(gr_vector_const_void_star& input_items); double search_maximum(); void get_assistance(); @@ -96,22 +101,22 @@ private: void redefine_grid(); void free_grid_memory(); - long d_fs_in; - int d_samples_per_ms; - int d_max_dwells; - unsigned int d_doppler_resolution; - int d_gnuradio_forecast_samples; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_max_dwells; + uint32_t d_doppler_resolution; + int32_t d_gnuradio_forecast_samples; float d_threshold; std::string d_satellite_str; - int d_doppler_max; - int d_doppler_min; - int d_config_doppler_max; - int d_config_doppler_min; + int32_t d_doppler_max; + int32_t d_doppler_min; + int32_t d_config_doppler_max; + int32_t d_config_doppler_min; - int d_num_doppler_points; - int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_fft_size; + int32_t d_num_doppler_points; + int32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_fft_size; uint64_t d_sample_counter; gr_complex* d_carrier; gr_complex* d_fft_codes; @@ -122,17 +127,17 @@ private: gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_input_power; float d_test_statistics; std::ofstream d_dump_file; - int d_state; + int32_t d_state; bool d_active; bool d_disable_assist; - int d_well_count; + int32_t d_well_count; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; @@ -155,7 +160,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_test_statistics; } @@ -185,7 +190,7 @@ public: * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -204,7 +209,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -213,7 +218,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - void set_doppler_step(unsigned int doppler_step); + void set_doppler_step(uint32_t doppler_step); /*! * \brief Parallel Code Phase Search Acquisition signal processing. diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index e0872e9eb..f9ae9b104 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -35,22 +35,24 @@ */ #include "pcps_cccwsr_acquisition_cc.h" -#include -#include +#include "control_message_factory.h" +#include "GPS_L1_CA.h" // GPS_TWO_PI #include #include #include #include -#include "control_message_factory.h" -#include "GPS_L1_CA.h" //GPS_TWO_PI - +#include +#include using google::LogMessage; pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) { return pcps_cccwsr_acquisition_cc_sptr( @@ -58,10 +60,14 @@ pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( samples_per_ms, samples_per_code, dump, std::move(dump_filename))); } + pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool dump, std::string dump_filename) : gr::block("pcps_cccwsr_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), @@ -116,7 +122,7 @@ pcps_cccwsr_acquisition_cc::~pcps_cccwsr_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -175,8 +181,8 @@ void pcps_cccwsr_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -184,11 +190,11 @@ void pcps_cccwsr_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; @@ -197,7 +203,7 @@ void pcps_cccwsr_acquisition_cc::init() } -void pcps_cccwsr_acquisition_cc::set_state(int state) +void pcps_cccwsr_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) @@ -225,7 +231,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -254,7 +260,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; uint32_t indext_plus = 0; @@ -281,11 +287,11 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); @@ -320,7 +326,7 @@ int pcps_cccwsr_acquisition_cc::general_work(int noutput_items, // d_data_correlation. memcpy(d_pilot_correlation, d_ifft->get_outbuf(), sizeof(gr_complex) * d_fft_size); - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_correlation_plus[i] = std::complex( d_data_correlation[i].real() - d_pilot_correlation[i].imag(), diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h index 00348daa9..072eb1b83 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h @@ -50,10 +50,15 @@ class pcps_cccwsr_acquisition_cc; typedef boost::shared_ptr pcps_cccwsr_acquisition_cc_sptr; pcps_cccwsr_acquisition_cc_sptr -pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, - bool dump, std::string dump_filename); +pcps_cccwsr_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with @@ -63,40 +68,40 @@ class pcps_cccwsr_acquisition_cc : public gr::block { private: friend pcps_cccwsr_acquisition_cc_sptr - pcps_cccwsr_make_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_cccwsr_make_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool dump, std::string dump_filename); - pcps_cccwsr_acquisition_cc(unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_cccwsr_acquisition_cc(uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - long d_fs_in; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_code_data; gr_complex* d_fft_code_pilot; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -108,9 +113,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -132,7 +137,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -164,13 +169,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -189,7 +194,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -198,7 +203,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 159f09978..010285c1f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -43,10 +43,13 @@ using google::LogMessage; pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( - unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t folding_factor, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename) @@ -63,10 +66,10 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( - unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename) : gr::block("pcps_quicksync_acquisition_cc", @@ -97,7 +100,7 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( d_magnitude = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(float), volk_gnsssdr_get_alignment())); d_magnitude_folded = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - d_possible_delay = new unsigned int[d_folding_factor]; + d_possible_delay = new uint32_t[d_folding_factor]; d_corr_output_f = new float[d_folding_factor]; /*Create the d_code signal , which would store the values of the code in its @@ -138,7 +141,7 @@ pcps_quicksync_acquisition_cc::~pcps_quicksync_acquisition_cc() //DLOG(INFO) << "START DESTROYER"; if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); } @@ -176,7 +179,7 @@ void pcps_quicksync_acquisition_cc::set_local_code(std::complex* code) /*perform folding of the code by the factorial factor parameter. Notice that folding of the code in the time stage would result in a downsampled spectrum in the frequency domain after applying the fftw operation*/ - for (unsigned int i = 0; i < d_folding_factor; i++) + for (uint32_t i = 0; i < d_folding_factor; i++) { std::transform((code + i * d_fft_size), (code + ((i + 1) * d_fft_size)), d_fft_if->get_inbuf(), d_fft_if->get_inbuf(), @@ -209,8 +212,8 @@ void pcps_quicksync_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -218,10 +221,10 @@ void pcps_quicksync_acquisition_cc::init() // Create the carrier Doppler wipeoff signals d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_samples_per_code * d_folding_factor * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; @@ -231,7 +234,7 @@ void pcps_quicksync_acquisition_cc::init() } -void pcps_quicksync_acquisition_cc::set_state(int state) +void pcps_quicksync_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) @@ -270,7 +273,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, * 6. Declare positive or negative acquisition using a message queue */ //DLOG(INFO) << "START GENERAL WORK"; - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL //std::cout<<"general_work in quicksync gnuradio block"<(input_items[0]); //Get the input samples pointer @@ -349,7 +352,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_samples_per_code * d_folding_factor); d_input_power /= static_cast(d_samples_per_code * d_folding_factor); - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { /*Ensure that the signal is going to start with all samples at zero. This is done to avoid over acumulation when performing @@ -360,7 +363,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Doppler search steps and then multiplication of the incoming signal with the doppler wipeoffs to eliminate frequency offset */ - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; /*Perform multiplication of the incoming signal with the complex exponential vector. This removes the frequency doppler @@ -372,7 +375,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, /*Perform folding of the carrier wiped-off incoming signal. Since superlinear method is being used the folding factor in the incoming raw data signal is of d_folding_factor^2*/ - for (int i = 0; i < static_cast(d_folding_factor * d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor * d_folding_factor); i++) { std::transform((in_temp + i * d_fft_size), (in_temp + ((i + 1) * d_fft_size)), @@ -423,17 +426,17 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, restarted between consecutive dwells in multidwell operation.*/ if (d_test_statistics < (d_mag / d_input_power) || !d_bit_transition_flag) { - unsigned int detected_delay_samples_folded = 0; + uint32_t detected_delay_samples_folded = 0; detected_delay_samples_folded = (indext % d_samples_per_code); gr_complex complex_acumulator[100]; //gr_complex complex_acumulator[d_folding_factor]; - for (int i = 0; i < static_cast(d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) { d_possible_delay[i] = detected_delay_samples_folded + (i)*d_fft_size; } - for (int i = 0; i < static_cast(d_folding_factor); i++) + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) { /*Copy a signal of 1 code length into suggested buffer. The copied signal must have doppler effect corrected*/ @@ -447,7 +450,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, of a shift*/ volk_32fc_x2_multiply_32fc(corr_output, in_1code, d_code, d_samples_per_code); - for (int j = 0; j < d_samples_per_code; j++) + for (int32_t j = 0; j < d_samples_per_code; j++) { complex_acumulator[i] += (corr_output[j]); } @@ -532,7 +535,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay correlation output"; - for (int i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; @@ -561,7 +564,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay corr output"; - for (int i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h index 56f363dbf..e933d1a7a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h @@ -67,10 +67,14 @@ typedef boost::shared_ptr pcps_quicksync_acquisition_cc_sptr; pcps_quicksync_acquisition_cc_sptr -pcps_quicksync_make_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, +pcps_quicksync_make_acquisition_cc( + uint32_t folding_factor, + uint32_t sampled_ms, + uint32_t max_dwells, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); @@ -86,56 +90,56 @@ class pcps_quicksync_acquisition_cc : public gr::block { private: friend pcps_quicksync_acquisition_cc_sptr - pcps_quicksync_make_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_quicksync_make_acquisition_cc(uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); - pcps_quicksync_acquisition_cc(unsigned int folding_factor, - unsigned int sampled_ms, unsigned int max_dwells, - unsigned int doppler_max, long fs_in, - int samples_per_ms, int samples_per_code, + pcps_quicksync_acquisition_cc(uint32_t folding_factor, + uint32_t sampled_ms, uint32_t max_dwells, + uint32_t doppler_max, int64_t fs_in, + int32_t samples_per_ms, int32_t samples_per_code, bool bit_transition_flag, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); gr_complex* d_code; - unsigned int d_folding_factor; // also referred in the paper as 'p' + uint32_t d_folding_factor; // also referred in the paper as 'p' float* d_corr_acumulator; - unsigned int* d_possible_delay; + uint32_t * d_possible_delay; float* d_corr_output_f; float* d_magnitude_folded; gr_complex* d_signal_folded; gr_complex* d_code_folded; float d_noise_floor_power; - long d_fs_in; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_max_dwells; - unsigned int d_well_count; - unsigned int d_fft_size; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_max_dwells; + uint32_t d_well_count; + uint32_t d_fft_size; uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_codes; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_fft_if2; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -144,9 +148,9 @@ private: bool d_bit_transition_flag; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -168,7 +172,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -199,13 +203,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -224,7 +228,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -233,7 +237,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 47617e953..6d1b4917c 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -61,10 +61,14 @@ using google::LogMessage; pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( - unsigned int sampled_ms, unsigned int doppler_max, - long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, bool dump, std::string dump_filename) { return pcps_tong_acquisition_cc_sptr( @@ -73,10 +77,14 @@ pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( } pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( - unsigned int sampled_ms, unsigned int doppler_max, - long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, bool dump, std::string dump_filename) : gr::block("pcps_tong_acquisition_cc", gr::io_signature::make(1, 1, sizeof(gr_complex) * sampled_ms * samples_per_ms), @@ -130,7 +138,7 @@ pcps_tong_acquisition_cc::~pcps_tong_acquisition_cc() { if (d_num_doppler_bins > 0) { - for (unsigned int i = 0; i < d_num_doppler_bins; i++) + for (uint32_t i = 0; i < d_num_doppler_bins; i++) { volk_gnsssdr_free(d_grid_doppler_wipeoffs[i]); volk_gnsssdr_free(d_grid_data[i]); @@ -176,8 +184,8 @@ void pcps_tong_acquisition_cc::init() // Count the number of bins d_num_doppler_bins = 0; - for (int doppler = static_cast(-d_doppler_max); - doppler <= static_cast(d_doppler_max); + for (auto doppler = static_cast(-d_doppler_max); + doppler <= static_cast(d_doppler_max); doppler += d_doppler_step) { d_num_doppler_bins++; @@ -186,11 +194,11 @@ void pcps_tong_acquisition_cc::init() // Create the carrier Doppler wipeoff signals and allocate data grid. d_grid_doppler_wipeoffs = new gr_complex *[d_num_doppler_bins]; d_grid_data = new float *[d_num_doppler_bins]; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { d_grid_doppler_wipeoffs[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - int doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + int32_t doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; float phase_step_rad = GPS_TWO_PI * doppler / static_cast(d_fs_in); float _phase[1]; _phase[0] = 0; @@ -198,14 +206,14 @@ void pcps_tong_acquisition_cc::init() d_grid_data[doppler_index] = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(float), volk_gnsssdr_get_alignment())); - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } } } -void pcps_tong_acquisition_cc::set_state(int state) +void pcps_tong_acquisition_cc::set_state(int32_t state) { d_state = state; if (d_state == 1) @@ -220,9 +228,9 @@ void pcps_tong_acquisition_cc::set_state(int state) d_input_power = 0.0; d_test_statistics = 0.0; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } @@ -241,7 +249,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items __attribute__((unused))) { - int acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL + int32_t acquisition_message = -1; //0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL switch (d_state) { @@ -260,9 +268,9 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_input_power = 0.0; d_test_statistics = 0.0; - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { - for (unsigned int i = 0; i < d_fft_size; i++) + for (uint32_t i = 0; i < d_fft_size; i++) { d_grid_data[doppler_index][i] = 0; } @@ -280,7 +288,7 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, case 1: { // initialize acquisition algorithm - int doppler; + int32_t doppler; uint32_t indext = 0; float magt = 0.0; const auto *in = reinterpret_cast(input_items[0]); //Get the input samples pointer @@ -304,11 +312,11 @@ int pcps_tong_acquisition_cc::general_work(int noutput_items, d_input_power /= static_cast(d_fft_size); // 2- Doppler frequency search loop - for (unsigned int doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) + for (uint32_t doppler_index = 0; doppler_index < d_num_doppler_bins; doppler_index++) { // doppler search steps - doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; + doppler = -static_cast(d_doppler_max) + d_doppler_step * doppler_index; volk_32fc_x2_multiply_32fc(d_fft_if->get_inbuf(), in, d_grid_doppler_wipeoffs[doppler_index], d_fft_size); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h index 7508fb42c..af538ebf1 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h @@ -64,11 +64,17 @@ class pcps_tong_acquisition_cc; typedef boost::shared_ptr pcps_tong_acquisition_cc_sptr; pcps_tong_acquisition_cc_sptr -pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, - bool dump, std::string dump_filename); +pcps_tong_make_acquisition_cc( + uint32_t sampled_ms, + uint32_t doppler_max, + int64_t fs_in, + int32_t samples_per_ms, + int32_t samples_per_code, + uint32_t tong_init_val, + uint32_t tong_max_val, + uint32_t tong_max_dwells, + bool dump, + std::string dump_filename); /*! * \brief This class implements a Parallel Code Phase Search Acquisition with @@ -78,45 +84,45 @@ class pcps_tong_acquisition_cc : public gr::block { private: friend pcps_tong_acquisition_cc_sptr - pcps_tong_make_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + pcps_tong_make_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, + int64_t fs_in, int32_t samples_per_ms, + int32_t samples_per_code, uint32_t tong_init_val, + uint32_t tong_max_val, uint32_t tong_max_dwells, bool dump, std::string dump_filename); - pcps_tong_acquisition_cc(unsigned int sampled_ms, unsigned int doppler_max, - long fs_in, int samples_per_ms, - int samples_per_code, unsigned int tong_init_val, - unsigned int tong_max_val, unsigned int tong_max_dwells, + pcps_tong_acquisition_cc(uint32_t sampled_ms, uint32_t doppler_max, + int64_t fs_in, int32_t samples_per_ms, + int32_t samples_per_code, uint32_t tong_init_val, + uint32_t tong_max_val, uint32_t tong_max_dwells, bool dump, std::string dump_filename); - void calculate_magnitudes(gr_complex* fft_begin, int doppler_shift, - int doppler_offset); + void calculate_magnitudes(gr_complex* fft_begin, int32_t doppler_shift, + int32_t doppler_offset); - long d_fs_in; - int d_samples_per_ms; - int d_samples_per_code; - unsigned int d_doppler_resolution; + int64_t d_fs_in; + int32_t d_samples_per_ms; + int32_t d_samples_per_code; + uint32_t d_doppler_resolution; float d_threshold; std::string d_satellite_str; - unsigned int d_doppler_max; - unsigned int d_doppler_step; - unsigned int d_sampled_ms; - unsigned int d_dwell_count; - unsigned int d_tong_count; - unsigned int d_tong_init_val; - unsigned int d_tong_max_val; - unsigned int d_tong_max_dwells; - unsigned int d_fft_size; + uint32_t d_doppler_max; + uint32_t d_doppler_step; + uint32_t d_sampled_ms; + uint32_t d_dwell_count; + uint32_t d_tong_count; + uint32_t d_tong_init_val; + uint32_t d_tong_max_val; + uint32_t d_tong_max_dwells; + uint32_t d_fft_size; uint64_t d_sample_counter; gr_complex** d_grid_doppler_wipeoffs; - unsigned int d_num_doppler_bins; + uint32_t d_num_doppler_bins; gr_complex* d_fft_codes; float** d_grid_data; gr::fft::fft_complex* d_fft_if; gr::fft::fft_complex* d_ifft; Gnss_Synchro* d_gnss_synchro; - unsigned int d_code_phase; + uint32_t d_code_phase; float d_doppler_freq; float d_mag; float* d_magnitude; @@ -124,9 +130,9 @@ private: float d_test_statistics; std::ofstream d_dump_file; bool d_active; - int d_state; + int32_t d_state; bool d_dump; - unsigned int d_channel; + uint32_t d_channel; std::string d_dump_filename; public: @@ -148,7 +154,7 @@ public: /*! * \brief Returns the maximum peak of grid search. */ - inline unsigned int mag() const + inline uint32_t mag() const { return d_mag; } @@ -179,13 +185,13 @@ public: * first available sample. * \param state - int=1 forces start of acquisition */ - void set_state(int state); + void set_state(int32_t state); /*! * \brief Set acquisition channel unique ID * \param channel - receiver channel. */ - inline void set_channel(unsigned int channel) + inline void set_channel(uint32_t channel) { d_channel = channel; } @@ -204,7 +210,7 @@ public: * \brief Set maximum Doppler grid search * \param doppler_max - Maximum Doppler shift considered in the grid search [Hz]. */ - inline void set_doppler_max(unsigned int doppler_max) + inline void set_doppler_max(uint32_t doppler_max) { d_doppler_max = doppler_max; } @@ -213,7 +219,7 @@ public: * \brief Set Doppler steps for the grid search * \param doppler_step - Frequency bin of the search grid [Hz]. */ - inline void set_doppler_step(unsigned int doppler_step) + inline void set_doppler_step(uint32_t doppler_step) { d_doppler_step = doppler_step; } diff --git a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc index 0c5a29c24..b89fec1ed 100644 --- a/src/algorithms/data_type_adapter/adapters/byte_to_short.cc +++ b/src/algorithms/data_type_adapter/adapters/byte_to_short.cc @@ -31,7 +31,7 @@ #include "byte_to_short.h" #include "configuration_interface.h" #include - +#include #include @@ -51,7 +51,7 @@ ByteToShort::ByteToShort(ConfigurationInterface* configuration, std::string role dump_ = config_->property(role_ + ".dump", false); dump_filename_ = config_->property(role_ + ".dump_filename", default_dump_filename); - size_t item_size = sizeof(short); + size_t item_size = sizeof(int16_t); gr_char_to_short_ = gr::blocks::char_to_short::make(); diff --git a/src/algorithms/input_filter/adapters/fir_filter.cc b/src/algorithms/input_filter/adapters/fir_filter.cc index 097ac7a22..27659019f 100644 --- a/src/algorithms/input_filter/adapters/fir_filter.cc +++ b/src/algorithms/input_filter/adapters/fir_filter.cc @@ -291,11 +291,11 @@ gr::basic_block_sptr FirFilter::get_left_block() { return cbyte_to_float_x2_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { return cbyte_to_float_x2_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { return cshort_to_float_x2_; } @@ -321,11 +321,11 @@ gr::basic_block_sptr FirFilter::get_right_block() { return float_to_complex_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cbyte") && (output_item_type_ == "cbyte")) { return char_x2_cbyte_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "cshort") && (output_item_type_ == "gr_complex")) { return float_to_complex_; } diff --git a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc index c0c92c884..9d5901b38 100644 --- a/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc +++ b/src/algorithms/input_filter/adapters/freq_xlating_fir_filter.cc @@ -331,11 +331,11 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_left_block() { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { return gr_char_to_short_; } @@ -365,11 +365,11 @@ gr::basic_block_sptr FreqXlatingFirFilter::get_right_block() { return freq_xlating_fir_filter_scf_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) + if ((taps_item_type_ == "float") && (input_item_type_ == "short") && (output_item_type_ == "cshort")) { return short_x2_to_cshort_; } - else if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) + if ((taps_item_type_ == "float") && (input_item_type_ == "byte") && (output_item_type_ == "gr_complex")) { return freq_xlating_fir_filter_scf_; } diff --git a/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc b/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc index 0fc773efa..6f53c6099 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/beamformer.cc @@ -49,7 +49,7 @@ beamformer::beamformer() { //initialize weight vector - if (posix_memalign((void **)&weight_vector, 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0) + if (posix_memalign(reinterpret_cast(&weight_vector), 16, GNSS_SDR_BEAMFORMER_CHANNELS * sizeof(gr_complex)) == 0) { }; diff --git a/src/algorithms/libs/galileo_e5_signal_processing.cc b/src/algorithms/libs/galileo_e5_signal_processing.cc index 7874acff4..400aed192 100644 --- a/src/algorithms/libs/galileo_e5_signal_processing.cc +++ b/src/algorithms/libs/galileo_e5_signal_processing.cc @@ -119,7 +119,7 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex* _dest, char _Sig if (_fs != _codeFreqBasis) { std::complex* _resampled_signal; - if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0) + if (posix_memalign(reinterpret_cast(&_resampled_signal), 16, _samplesPerCode * sizeof(gr_complex)) == 0) { }; resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); // resamples code to fs diff --git a/src/algorithms/libs/gnss_sdr_valve.cc b/src/algorithms/libs/gnss_sdr_valve.cc index 8ef8eb08d..b613f3e2b 100644 --- a/src/algorithms/libs/gnss_sdr_valve.cc +++ b/src/algorithms/libs/gnss_sdr_valve.cc @@ -40,7 +40,7 @@ #include gnss_sdr_valve::gnss_sdr_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph) : gr::sync_block("valve", gr::io_signature::make(1, 1, sizeof_stream_item), @@ -54,14 +54,14 @@ gnss_sdr_valve::gnss_sdr_valve(size_t sizeof_stream_item, } -boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, unsigned long long nitems, gr::msg_queue::sptr queue, bool stop_flowgraph) +boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph) { boost::shared_ptr valve_(new gnss_sdr_valve(sizeof_stream_item, nitems, std::move(queue), stop_flowgraph)); return valve_; } -boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, unsigned long long nitems, gr::msg_queue::sptr queue) +boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, uint64_t nitems, gr::msg_queue::sptr queue) { boost::shared_ptr valve_(new gnss_sdr_valve(sizeof_stream_item, nitems, std::move(queue), true)); return valve_; @@ -93,7 +93,7 @@ int gnss_sdr_valve::work(int noutput_items, usleep(1000000); return 0; // do not produce or consume } - unsigned long long n = std::min(d_nitems - d_ncopied_items, static_cast(noutput_items)); + uint64_t n = std::min(d_nitems - d_ncopied_items, static_cast(noutput_items)); if (n == 0) return 0; memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0)); d_ncopied_items += n; diff --git a/src/algorithms/libs/gnss_sdr_valve.h b/src/algorithms/libs/gnss_sdr_valve.h index 8fe7140b6..a166ad44e 100644 --- a/src/algorithms/libs/gnss_sdr_valve.h +++ b/src/algorithms/libs/gnss_sdr_valve.h @@ -37,13 +37,14 @@ #include #include #include +#include boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue); boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph); @@ -54,22 +55,22 @@ boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, class gnss_sdr_valve : public gr::sync_block { friend boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue); friend boost::shared_ptr gnss_sdr_make_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph); - unsigned long long d_nitems; - unsigned long long d_ncopied_items; + uint64_t d_nitems; + uint64_t d_ncopied_items; gr::msg_queue::sptr d_queue; bool d_stop_flowgraph; bool d_open_valve; public: gnss_sdr_valve(size_t sizeof_stream_item, - unsigned long long nitems, + uint64_t nitems, gr::msg_queue::sptr queue, bool stop_flowgraph); void open_valve(); diff --git a/src/algorithms/libs/pass_through.cc b/src/algorithms/libs/pass_through.cc index 731fa6ba7..32b8b65c8 100644 --- a/src/algorithms/libs/pass_through.cc +++ b/src/algorithms/libs/pass_through.cc @@ -157,11 +157,8 @@ gr::basic_block_sptr Pass_Through::get_left_block() { return conjugate_ic_; } - else - { - LOG(WARNING) << "Setting inverted_spectrum to true with item_type " - << item_type_ << " is not defined and has no effect."; - } + LOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; } return kludge_copy_; @@ -184,11 +181,8 @@ gr::basic_block_sptr Pass_Through::get_right_block() { return conjugate_ic_; } - else - { - DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " - << item_type_ << " is not defined and has no effect."; - } + DLOG(WARNING) << "Setting inverted_spectrum to true with item_type " + << item_type_ << " is not defined and has no effect."; } return kludge_copy_; diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 14d90b902..393652143 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -63,6 +63,7 @@ #include #include #include +#include /* macros --------------------------------------------------------------------*/ diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index baae973c5..162778f9a 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -66,7 +66,7 @@ int getindex(double value, const double *range) if (range[2] == 0.0) return 0; if (range[1] > 0.0 && (value < range[0] || range[1] < value)) return -1; if (range[1] < 0.0 && (value < range[1] || range[0] < value)) return -1; - return (int)floor((value - range[0]) / range[2] + 0.5); + return static_cast(floor((value - range[0]) / range[2] + 0.5)); } @@ -103,7 +103,7 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts, if (nav->nt >= nav->ntmax) { nav->ntmax += 256; - if (!(nav_tec = (tec_t *)realloc(nav->tec, sizeof(tec_t) * nav->ntmax))) + if (!(nav_tec = static_cast(realloc(nav->tec, sizeof(tec_t) * nav->ntmax)))) { trace(1, "readionex malloc error ntmax=%d\n", nav->ntmax); free(nav->tec); @@ -125,8 +125,8 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts, } n = ndata[0] * ndata[1] * ndata[2]; - if (!(p->data = (double *)malloc(sizeof(double) * n)) || - !(p->rms = (float *)malloc(sizeof(float) * n))) + if (!(p->data = static_cast(malloc(sizeof(double) * n))) || + !(p->rms = static_cast(malloc(sizeof(float) * n)))) { return nullptr; } @@ -310,7 +310,7 @@ int readionexb(FILE *fp, const double *lats, const double *lons, if (type == 1) p->data[index] = x * std::pow(10.0, nexp); else - p->rms[index] = (float)(x * std::pow(10.0, nexp)); + p->rms[index] = static_cast(x * std::pow(10.0, nexp)); } } } @@ -384,7 +384,7 @@ void readtec(const char *file, nav_t *nav, int opt) } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { for (i--; i >= 0; i--) free(efiles[i]); return; @@ -395,7 +395,7 @@ void readtec(const char *file, nav_t *nav, int opt) for (i = 0; i < n; i++) { - if (!(fp = fopen(efiles[i], "r"))) + if (!(fp = fopen(efiles[i], "re"))) { trace(2, "ionex file open error %s\n", efiles[i]); continue; @@ -447,9 +447,9 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, a = dlat / tec->lats[2]; b = dlon / tec->lons[2]; - i = (int)floor(a); + i = static_cast(floor(a)); a -= i; - j = (int)floor(b); + j = static_cast(floor(b)); b -= j; /* get gridded tec data */ diff --git a/src/algorithms/libs/rtklib/rtklib_lambda.cc b/src/algorithms/libs/rtklib/rtklib_lambda.cc index 74e247aa0..ac200a8b9 100644 --- a/src/algorithms/libs/rtklib/rtklib_lambda.cc +++ b/src/algorithms/libs/rtklib/rtklib_lambda.cc @@ -84,10 +84,10 @@ void gauss(int n, double *L, double *Z, int i, int j) { int k, mu; - if ((mu = (int)ROUND_LAMBDA(L[i + j * n])) != 0) + if ((mu = static_castROUND_LAMBDA(L[i + j * n])) != 0) { - for (k = i; k < n; k++) L[k + n * j] -= (double)mu * L[k + i * n]; - for (k = 0; k < n; k++) Z[k + n * j] -= (double)mu * Z[k + i * n]; + for (k = i; k < n; k++) L[k + n * j] -= static_cast(mu) * L[k + i * n]; + for (k = 0; k < n; k++) Z[k + n * j] -= static_cast(mu) * Z[k + i * n]; } } diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index 5c3a3255f..016037f77 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -609,11 +609,11 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, sol->dtr[2] = x[5] / SPEED_OF_LIGHT; /* gal-gps time offset (s) */ sol->dtr[3] = x[6] / SPEED_OF_LIGHT; /* bds-gps time offset (s) */ for (j = 0; j < 6; j++) sol->rr[j] = j < 3 ? x[j] : 0.0; - for (j = 0; j < 3; j++) sol->qr[j] = (float)Q[j + j * NX]; - sol->qr[3] = (float)Q[1]; /* cov xy */ - sol->qr[4] = (float)Q[2 + NX]; /* cov yz */ - sol->qr[5] = (float)Q[2]; /* cov zx */ - sol->ns = (unsigned char)ns; + for (j = 0; j < 3; j++) sol->qr[j] = static_cast(Q[j + j * NX]); + sol->qr[3] = static_cast(Q[1]); /* cov xy */ + sol->qr[4] = static_cast(Q[2 + NX]); /* cov yz */ + sol->qr[5] = static_cast(Q[2]); /* cov zx */ + sol->ns = static_cast(ns); sol->age = sol->ratio = 0.0; /* validate solution */ @@ -652,7 +652,7 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, trace(3, "raim_fde: %s n=%2d\n", time_str(obs[0].time, 0), n); - if (!(obs_e = (obsd_t *)malloc(sizeof(obsd_t) * n))) return 0; + if (!(obs_e = static_cast(malloc(sizeof(obsd_t) * n)))) return 0; rs_e = mat(6, n); dts_e = mat(2, n); vare_e = mat(1, n); diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index 81265a9bc..30f07161d 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -518,7 +518,7 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) return 0; } - rtk->sol.ratio = (float)(MIN_PPP(s[1] / s[0], 999.9)); + rtk->sol.ratio = static_cast(MIN_PPP(s[1] / s[0], 999.9)); /* varidation by ratio-test */ if (rtk->opt.thresar[0] > 0.0 && rtk->sol.ratio < rtk->opt.thresar[0]) @@ -1113,7 +1113,7 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) /* reset phase-bias if expire obs outage counter */ for (i = 0; i < MAXSAT; i++) { - if (++rtk->ssat[i].outc[0] > (unsigned int)rtk->opt.maxout) + if (++rtk->ssat[i].outc[0] > static_cast(rtk->opt.maxout)) { initx(rtk, 0.0, 0.0, IB_PPP(i + 1, &rtk->opt)); } @@ -1492,11 +1492,11 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->x[i]; - rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx]; + rtk->sol.qr[i] = static_cast(rtk->P[i + i * rtk->nx]); } - rtk->sol.qr[3] = (float)rtk->P[1]; - rtk->sol.qr[4] = (float)rtk->P[2 + rtk->nx]; - rtk->sol.qr[5] = (float)rtk->P[2]; + rtk->sol.qr[3] = static_cast(rtk->P[1]); + rtk->sol.qr[4] = static_cast(rtk->P[2 + rtk->nx]); + rtk->sol.qr[5] = static_cast(rtk->P[2]); rtk->sol.dtr[0] = rtk->x[IC_PPP(0, opt)]; rtk->sol.dtr[1] = rtk->x[IC_PPP(1, opt)] - rtk->x[IC_PPP(0, opt)]; for (i = 0; i < n && i < MAXOBS; i++) diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 299f883ab..3da6b8b5b 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -98,12 +98,12 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, { if (i == 2) { - ns = (int)str2num(buff, 4, 2); + ns = static_cast(str2num(buff, 4, 2)); } for (j = 0; j < 17 && k < ns; j++) { sys = code2sys(buff[9 + 3 * j]); - prn = (int)str2num(buff, 10 + 3 * j, 2); + prn = static_cast(str2num(buff, 10 + 3 * j, 2)); if (k < MAXSAT) sats[k++] = satno(sys, prn); } } @@ -130,7 +130,7 @@ int addpeph(nav_t *nav, peph_t *peph) if (nav->ne >= nav->nemax) { nav->nemax += 256; - if (!(nav_peph = (peph_t *)realloc(nav->peph, sizeof(peph_t) * nav->nemax))) + if (!(nav_peph = static_cast(realloc(nav->peph, sizeof(peph_t) * nav->nemax)))) { trace(1, "readsp3b malloc error n=%d\n", nav->nemax); free(nav->peph); @@ -190,7 +190,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) continue; sys = buff[1] == ' ' ? SYS_GPS : code2sys(buff[1]); - prn = (int)str2num(buff, 2, 2); + prn = static_cast(str2num(buff, 2, 2)); if (sys == SYS_SBS) prn += 100; else if (sys == SYS_QZS) @@ -223,7 +223,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do } if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0) { - peph.std[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12)); + peph.std[sat - 1][j] = static_cast(std::pow(base, std) * (j < 3 ? 1e-3 : 1e-12)); } } else if (v) @@ -234,7 +234,7 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, do } if ((base = bfact[j < 3 ? 0 : 1]) > 0.0 && std > 0.0) { - peph.vst[sat - 1][j] = (float)(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16)); + peph.vst[sat - 1][j] = static_cast(std::pow(base, std) * (j < 3 ? 1e-7 : 1e-16)); } } } @@ -315,7 +315,7 @@ void readsp3(const char *file, nav_t *nav, int opt) for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { for (i--; i >= 0; i--) free(efiles[i]); return; @@ -331,7 +331,7 @@ void readsp3(const char *file, nav_t *nav, int opt) if (!strstr(ext + 1, "sp3") && !strstr(ext + 1, ".SP3") && !strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) continue; - if (!(fp = fopen(efiles[i], "r"))) + if (!(fp = fopen(efiles[i], "re"))) { trace(2, "sp3 file open error %s\n", efiles[i]); continue; @@ -389,7 +389,7 @@ int readdcbf(const char *file, nav_t *nav, const sta_t *sta) trace(3, "readdcbf: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "dcb parameters file open error: %s\n", file); return 0; @@ -453,7 +453,7 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) } for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { for (i--; i >= 0; i--) free(efiles[i]); return 0; @@ -490,7 +490,7 @@ int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, if (nav->nf >= nav->nfmax) { nav->nfmax = nav->nfmax <= 0 ? 2048 : nav->nfmax * 2; - if (!(nav_fcb = (fcbd_t *)realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax))) + if (!(nav_fcb = static_cast(realloc(nav->fcb, sizeof(fcbd_t) * nav->nfmax)))) { free(nav->fcb); nav->nf = nav->nfmax = 0; @@ -525,7 +525,7 @@ int readfcbf(const char *file, nav_t *nav) trace(3, "readfcbf: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "fcb parameters file open error: %s\n", file); return 0; @@ -578,7 +578,7 @@ int readfcb(const char *file, nav_t *nav) for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { for (i--; i >= 0; i--) free(efiles[i]); return 0; diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm.cc b/src/algorithms/libs/rtklib/rtklib_rtcm.cc index 56e46907c..c82065d2c 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm.cc @@ -113,9 +113,9 @@ int init_rtcm(rtcm_t *rtcm) rtcm->nav.geph = nullptr; /* reallocate memory for observation and ephemris buffer */ - if (!(rtcm->obs.data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS)) || - !(rtcm->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT)) || - !(rtcm->nav.geph = (geph_t *)malloc(sizeof(geph_t) * MAXPRNGLO))) + if (!(rtcm->obs.data = static_cast(malloc(sizeof(obsd_t) * MAXOBS))) || + !(rtcm->nav.eph = static_cast(malloc(sizeof(eph_t) * MAXSAT))) || + !(rtcm->nav.geph = static_cast(malloc(sizeof(geph_t) * MAXPRNGLO)))) { free_rtcm(rtcm); return 0; @@ -182,7 +182,7 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) /* synchronize frame */ if (rtcm->nbyte == 0) { - preamb = (unsigned char)(rtcm->word >> 22); + preamb = static_cast(rtcm->word >> 22); if (rtcm->word & 0x40000000) preamb ^= 0xFF; /* decode preamble */ if (preamb != RTCM2PREAMB) continue; @@ -330,7 +330,7 @@ int input_rtcm2f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm2(rtcm, (unsigned char)data))) return ret; + if ((ret = input_rtcm2(rtcm, static_cast(data)))) return ret; } return 0; /* return at every 4k bytes */ } @@ -352,7 +352,7 @@ int input_rtcm3f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm3(rtcm, (unsigned char)data))) return ret; + if ((ret = input_rtcm3(rtcm, static_cast(data)))) return ret; } return 0; /* return at every 4k bytes */ } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index 7bbec4a14..ef11206a5 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -173,7 +173,7 @@ double adjcp(rtcm_t *rtcm, int sat, int freq, double cp) int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock) { int lli = (!lock && !rtcm->lock[sat - 1][freq]) || lock < rtcm->lock[sat - 1][freq]; - rtcm->lock[sat - 1][freq] = (unsigned short)lock; + rtcm->lock[sat - 1][freq] = static_cast(lock); return lli; } @@ -181,7 +181,7 @@ int lossoflock(rtcm_t *rtcm, int sat, int freq, int lock) /* s/n ratio -----------------------------------------------------------------*/ unsigned char snratio(double snr) { - return (unsigned char)(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5); + return static_cast(snr <= 0.0 || 255.5 <= snr ? 0.0 : snr * 4.0 + 0.5); } @@ -337,7 +337,7 @@ int decode_type1002(rtcm_t *rtcm) } if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]); @@ -418,7 +418,7 @@ int decode_type1004(rtcm_t *rtcm) } if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; cp1 = adjcp(rtcm, sat, 0, ppr1 * 0.0005 / lam_carr[0]); @@ -428,11 +428,11 @@ int decode_type1004(rtcm_t *rtcm) rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25); rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C; - if (pr21 != (int)0xFFFFE000) + if (pr21 != static_cast(0xFFFFE000)) { rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02; } - if (ppr2 != (int)0xFFF80000) + if (ppr2 != static_cast(0xFFF80000)) { cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam_carr[1]); rtcm->obs.data[index].L[1] = pr1 / lam_carr[1] + cp2; @@ -449,7 +449,7 @@ int decode_type1004(rtcm_t *rtcm) /* get signed 38bit field ----------------------------------------------------*/ double getbits_38(const unsigned char *buff, int pos) { - return (double)getbits(buff, pos, 32) * 64.0 + getbitu(buff, pos + 32, 6); + return static_cast(getbits(buff, pos, 32)) * 64.0 + getbitu(buff, pos + 32, 6); } @@ -564,7 +564,7 @@ int decode_type1007(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); @@ -606,14 +606,14 @@ int decode_type1008(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); i += 8 + 8; for (j = 0; j < m && j < 31; j++) { - sno[j] = (char)getbitu(rtcm->buff, i, 8); + sno[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } } @@ -730,7 +730,7 @@ int decode_type1010(rtcm_t *rtcm) } if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { rtcm->obs.data[index].P[0] = pr1; lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7)); @@ -804,7 +804,7 @@ int decode_type1012(rtcm_t *rtcm) } if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; - if (ppr1 != (int)0xFFF80000) + if (ppr1 != static_cast(0xFFF80000)) { lam1 = SPEED_OF_LIGHT / (FREQ1_GLO + DFRQ1_GLO * (freq - 7)); rtcm->obs.data[index].P[0] = pr1; @@ -815,11 +815,11 @@ int decode_type1012(rtcm_t *rtcm) rtcm->obs.data[index].SNR[0] = snratio(cnr1 * 0.25); rtcm->obs.data[index].code[0] = code1 ? CODE_L1P : CODE_L1C; - if (pr21 != (int)0xFFFFE000) + if (pr21 != static_cast(0xFFFFE000)) { rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02; } - if (ppr2 != (int)0xFFF80000) + if (ppr2 != static_cast(0xFFF80000)) { lam2 = SPEED_OF_LIGHT / (FREQ2_GLO + DFRQ2_GLO * (freq - 7)); cp2 = adjcp(rtcm, sat, 1, ppr2 * 0.0005 / lam2); @@ -1189,32 +1189,32 @@ int decode_type1033(rtcm_t *rtcm) i += 12 + 8; for (j = 0; j < n && j < 31; j++) { - des[j] = (char)getbitu(rtcm->buff, i, 8); + des[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } setup = getbitu(rtcm->buff, i, 8); i += 8 + 8; for (j = 0; j < m && j < 31; j++) { - sno[j] = (char)getbitu(rtcm->buff, i, 8); + sno[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n1 && j < 31; j++) { - rec[j] = (char)getbitu(rtcm->buff, i, 8); + rec[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n2 && j < 31; j++) { - ver[j] = (char)getbitu(rtcm->buff, i, 8); + ver[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } i += 8; for (j = 0; j < n3 && j < 31; j++) { - rsn[j] = (char)getbitu(rtcm->buff, i, 8); + rsn[j] = static_cast(getbitu(rtcm->buff, i, 8)); i += 8; } } @@ -2222,7 +2222,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys) i += 14; if (mode <= ncode) { - cbias[codes[mode] - 1] = (float)bias; + cbias[codes[mode] - 1] = static_cast(bias); } else { @@ -2240,7 +2240,7 @@ int decode_ssr3(rtcm_t *rtcm, int sys) for (k = 0; k < MAXCODE; k++) { - rtcm->ssr[sat - 1].cbias[k] = (float)cbias[k]; + rtcm->ssr[sat - 1].cbias[k] = static_cast(cbias[k]); } rtcm->ssr[sat - 1].update = 1; } @@ -2579,7 +2579,7 @@ int decode_ssr7(rtcm_t *rtcm, int sys) for (k = 0; k < MAXCODE; k++) { rtcm->ssr[sat - 1].pbias[k] = pbias[k]; - rtcm->ssr[sat - 1].stdpb[k] = (float)stdpb[k]; + rtcm->ssr[sat - 1].stdpb[k] = static_cast(stdpb[k]); } } return 20; @@ -2773,11 +2773,11 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, /* doppler (hz) */ if (rr && rrf && rrf[j] > -1E12 && wl > 0.0) { - rtcm->obs.data[index].D[ind[k]] = (float)(-(rr[i] + rrf[j]) / wl); + rtcm->obs.data[index].D[ind[k]] = static_cast(-(rr[i] + rrf[j]) / wl); } rtcm->obs.data[index].LLI[ind[k]] = lossoflock(rtcm, sat, ind[k], lock[j]) + (half[j] ? 3 : 0); - rtcm->obs.data[index].SNR[ind[k]] = (unsigned char)(cnr[j] * 4.0); + rtcm->obs.data[index].SNR[ind[k]] = static_cast(cnr[j] * 4.0); rtcm->obs.data[index].code[ind[k]] = code[k]; } j++; diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index a62d649d0..71e08e7fe 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -153,7 +153,7 @@ char codepris[7][MAXFREQ][16] = { fatalfunc_t *fatalfunc = nullptr; /* fatal callback function */ /* crc tables generated by util/gencrc ---------------------------------------*/ -const unsigned short tbl_CRC16[] = { +const uint16_t tbl_CRC16[] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, @@ -519,7 +519,7 @@ int testsnr(int base, int freq, double el, double snr, if (!mask->ena[base] || freq < 0 || freq >= NFREQ) return 0; a = (el * R2D + 5.0) / 10.0; - i = (int)floor(a); + i = static_cast(floor(a)); a -= i; if (i < 1) minsnr = mask->mask[freq][0]; @@ -546,9 +546,9 @@ unsigned char obs2code(const char *obs, int *freq) if (freq) *freq = 0; for (i = 1; *obscodes[i]; i++) { - if (strcmp(obscodes[i], obs)) continue; + if (strcmp(obscodes[i], obs) != 0) continue; if (freq) *freq = obsfreqs[i]; - return (unsigned char)i; + return static_cast(i); } return CODE_NONE; } @@ -657,7 +657,7 @@ int getcodepri(int sys, unsigned char code, const char *opt) return str[1] == obs[1] ? 15 : 0; } /* search code priority */ - return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - (int)(p - codepris[i][j - 1]) : 0; + return (p = strchr(codepris[i][j - 1], obs[1])) ? 14 - static_cast(p - codepris[i][j - 1]) : 0; } @@ -680,8 +680,8 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len) int getbits(const unsigned char *buff, int pos, int len) { unsigned int bits = getbitu(buff, pos, len); - if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return (int)bits; - return (int)(bits | (~0u << len)); /* extend sign */ + if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return static_cast(bits); + return static_cast(bits | (~0u << len)); /* extend sign */ } @@ -714,7 +714,7 @@ void setbits(unsigned char *buff, int pos, int len, int data) data |= 1 << (len - 1); else data &= ~(1 << (len - 1)); /* set sign bit */ - setbitu(buff, pos, len, (unsigned int)data); + setbitu(buff, pos, len, static_cast(data)); } @@ -773,9 +773,9 @@ unsigned int rtk_crc24q(const unsigned char *buff, int len) * return : crc-16 parity * notes : see reference [10] A.3. *-----------------------------------------------------------------------------*/ -unsigned short rtk_crc16(const unsigned char *buff, int len) +uint16_t rtk_crc16(const unsigned char *buff, int len) { - unsigned short crc = 0; + uint16_t crc = 0; int i; trace(4, "rtk_crc16: len=%d\n", len); @@ -815,7 +815,7 @@ int decode_word(unsigned int word, unsigned char *data) } if (parity != (word & 0x3F)) return 0; - for (i = 0; i < 3; i++) data[i] = (unsigned char)(word >> (22 - i * 8)); + for (i = 0; i < 3; i++) data[i] = static_cast(word >> (22 - i * 8)); return 1; } @@ -830,7 +830,7 @@ double *mat(int n, int m) double *p; if (n <= 0 || m <= 0) return nullptr; - if (!(p = (double *)malloc(sizeof(double) * n * m))) + if (!(p = static_cast(malloc(sizeof(double) * n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -848,7 +848,7 @@ int *imat(int n, int m) int *p; if (n <= 0 || m <= 0) return nullptr; - if (!(p = (int *)malloc(sizeof(int) * n * m))) + if (!(p = static_cast(malloc(sizeof(int) * n * m)))) { fatalerr("integer matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -870,7 +870,7 @@ double *zeros(int n, int m) for (n = n * m - 1; n >= 0; n--) p[n] = 0.0; #else if (n <= 0 || m <= 0) return nullptr; - if (!(p = (double *)calloc(sizeof(double), n * m))) + if (!(p = static_cast(calloc(sizeof(double), n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); } @@ -983,7 +983,7 @@ void matmul(const char *tr, int n, int k, int m, double alpha, { int lda = tr[0] == 'T' ? m : n, ldb = tr[1] == 'T' ? k : m; - dgemm_((char *)tr, (char *)tr + 1, &n, &k, &m, &alpha, (double *)A, &lda, (double *)B, + dgemm_(const_cast(tr), const_cast(tr) + 1, &n, &k, &m, &alpha, const_cast(A), &lda, const_cast(B), &ldb, &beta, C, &n); } @@ -1028,7 +1028,7 @@ int solve(const char *tr, const double *A, const double *Y, int n, matcpy(B, A, n, n); matcpy(X, Y, n, m); dgetrf_(&n, &n, B, &n, ipiv, &info); - if (!info) dgetrs_((char *)tr, &n, &m, B, &n, ipiv, X, &n, &info); + if (!info) dgetrs_(const_cast(tr), &n, &m, B, &n, ipiv, X, &n, &info); free(ipiv); free(B); return info; @@ -1239,7 +1239,7 @@ double str2num(const char *s, int i, int n) double value; char str[256], *p = str; - if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < n) return 0.0; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < n) return 0.0; for (s += i; *s && --n >= 0; s++) { *p++ = *s == 'd' || *s == 'D' ? 'E' : *s; @@ -1261,7 +1261,7 @@ int str2time(const char *s, int i, int n, gtime_t *t) double ep[6]; char str[256], *p = str; - if (i < 0 || (int)strlen(s) < i || (int)sizeof(str) - 1 < i) return -1; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < i) return -1; for (s += i; *s && --n >= 0;) { *p++ = *s++; @@ -1285,14 +1285,14 @@ gtime_t epoch2time(const double *ep) { const int doy[] = {1, 32, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}; gtime_t time = {0, 0}; - int days, sec, year = (int)ep[0], mon = (int)ep[1], day = (int)ep[2]; + int days, sec, year = static_cast(ep[0]), mon = static_cast(ep[1]), day = static_cast(ep[2]); if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) return time; /* leap year if year%4==0 in 1901-2099 */ days = (year - 1970) * 365 + (year - 1969) / 4 + doy[mon - 1] + day - 2 + (year % 4 == 0 && mon >= 3 ? 1 : 0); - sec = (int)floor(ep[5]); - time.time = (time_t)days * 86400 + (int)ep[3] * 3600 + (int)ep[4] * 60 + sec; + sec = static_cast(floor(ep[5])); + time.time = static_cast(days) * 86400 + static_cast(ep[3]) * 3600 + static_cast(ep[4]) * 60 + sec; time.sec = ep[5] - sec; return time; } @@ -1313,8 +1313,8 @@ void time2epoch(gtime_t t, double *ep) int days, sec, mon, day; /* leap year if year%4==0 in 1901-2099 */ - days = (int)(t.time / 86400); - sec = (int)(t.time - (time_t)days * 86400); + days = static_cast(t.time / 86400); + sec = static_cast(t.time - static_cast(days) * 86400); for (day = days % 1461, mon = 0; mon < 48; mon++) { if (day >= mday[mon]) @@ -1342,8 +1342,8 @@ gtime_t gpst2time(int week, double sec) gtime_t t = epoch2time(gpst0); if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1376,8 +1376,8 @@ gtime_t gst2time(int week, double sec) gtime_t t = epoch2time(gst0); if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1392,10 +1392,10 @@ double time2gst(gtime_t t, int *week) { gtime_t t0 = epoch2time(gst0); time_t sec = t.time - t0.time; - int w = (int)(sec / (86400 * 7)); + int w = static_cast(sec / (86400 * 7)); if (week) *week = w; - return (double)(sec - (double)w * 86400 * 7) + t.sec; + return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1410,8 +1410,8 @@ gtime_t bdt2time(int week, double sec) gtime_t t = epoch2time(bdt0); if (sec < -1e9 || 1e9 < sec) sec = 0.0; - t.time += (time_t)86400 * 7 * week + (int)sec; - t.sec = sec - (int)sec; + t.time += static_cast(86400) * 7 * week + static_cast(sec); + t.sec = sec - static_cast(sec); return t; } @@ -1426,10 +1426,10 @@ double time2bdt(gtime_t t, int *week) { gtime_t t0 = epoch2time(bdt0); time_t sec = t.time - t0.time; - int w = (int)(sec / (86400 * 7)); + int w = static_cast(sec / (86400 * 7)); if (week) *week = w; - return (double)(sec - (double)w * 86400 * 7) + t.sec; + return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1445,7 +1445,7 @@ gtime_t timeadd(gtime_t t, double sec) t.sec += sec; tt = floor(t.sec); - t.time += (int)tt; + t.time += static_cast(tt); t.sec -= tt; return t; } @@ -1471,7 +1471,7 @@ gtime_t timeget(void) { gtime_t time; double ep[6] = {}; - struct timeval tv; + struct timeval tv{}; struct tm *tt; if (!gettimeofday(&tv, nullptr) && (tt = gmtime(&tv.tv_sec))) @@ -1547,7 +1547,7 @@ int read_leaps_usno(FILE *fp) ls[n][0] = y; ls[n][1] = m; ls[n][2] = d; - ls[n++][6] = (char)(19.0 - tai_utc); + ls[n++][6] = static_cast(19.0 - tai_utc); } for (i = 0; i < n; i++) for (j = 0; j < 7; j++) @@ -1574,7 +1574,7 @@ int read_leaps(const char *file) FILE *fp; int i, n; - if (!(fp = fopen(file, "r"))) return 0; + if (!(fp = fopen(file, "re"))) return 0; /* read leap seconds table by text or usno */ if (!(n = read_leaps_text(fp)) && !(n = read_leaps_usno(fp))) @@ -1794,8 +1794,8 @@ void sleepms(int ms) { struct timespec ts = {0, 0}; if (ms <= 0) return; - ts.tv_sec = (time_t)(ms / 1000); - ts.tv_nsec = (long)(ms % 1000 * 1000000); + ts.tv_sec = static_cast(ms / 1000); + ts.tv_nsec = static_cast(ms % 1000 * 1000000); nanosleep(&ts, nullptr); } @@ -2242,7 +2242,7 @@ void addpcv(const pcv_t *pcv, pcvs_t *pcvs) if (pcvs->nmax <= pcvs->n) { pcvs->nmax += 256; - if (!(pcvs_pcv = (pcv_t *)realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax))) + if (!(pcvs_pcv = static_cast(realloc(pcvs->pcv, sizeof(pcv_t) * pcvs->nmax)))) { trace(1, "addpcv: memory allocation error\n"); free(pcvs->pcv); @@ -2266,7 +2266,7 @@ int readngspcv(const char *file, pcvs_t *pcvs) int n = 0; char buff[256]; - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "ngs pcv file open error: %s\n", file); return 0; @@ -2327,7 +2327,7 @@ int readantex(const char *file, pcvs_t *pcvs) trace(3, "readantex: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "antex pcv file open error: %s\n", file); return 0; @@ -2521,7 +2521,7 @@ void readpos(const char *file, const char *rcv, double *pos) trace(3, "readpos: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { fprintf(stderr, "reference position file open error : %s\n", file); return; @@ -2536,10 +2536,10 @@ void readpos(const char *file, const char *rcv, double *pos) stas[np++][15] = '\0'; } fclose(fp); - len = (int)strlen(rcv); + len = static_cast(strlen(rcv)); for (i = 0; i < np; i++) { - if (strncmp(stas[i], rcv, len)) continue; + if (strncmp(stas[i], rcv, len) != 0) continue; for (j = 0; j < 3; j++) pos[j] = poss[i][j]; pos[0] *= D2R; pos[1] *= D2R; @@ -2582,10 +2582,10 @@ int readblq(const char *file, const char *sta, double *odisp) /* station name to upper case */ sscanf(sta, "%16s", staname); - for (p = staname; (*p = (char)toupper((int)(*p))); p++) + for (p = staname; (*p = static_cast(toupper(static_cast(*p)))); p++) ; - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "blq file open error: file=%s\n", file); return 0; @@ -2595,9 +2595,9 @@ int readblq(const char *file, const char *sta, double *odisp) if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) continue; if (sscanf(buff + 2, "%16s", name) < 1) continue; - for (p = name; (*p = (char)toupper((int)(*p))); p++) + for (p = name; (*p = static_cast(toupper(static_cast(*p)))); p++) ; - if (strcmp(name, staname)) continue; + if (strcmp(name, staname) != 0) continue; /* read blq record */ if (readblqrecord(fp, odisp)) @@ -2627,7 +2627,7 @@ int readerp(const char *file, erp_t *erp) trace(3, "readerp: file=%s\n", file); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "erp file open error: file=%s\n", file); return 0; @@ -2642,7 +2642,7 @@ int readerp(const char *file, erp_t *erp) if (erp->n >= erp->nmax) { erp->nmax = erp->nmax <= 0 ? 128 : erp->nmax * 2; - erp_data = (erpd_t *)realloc(erp->data, sizeof(erpd_t) * erp->nmax); + erp_data = static_cast(realloc(erp->data, sizeof(erpd_t) * erp->nmax)); if (!erp_data) { free(erp->data); @@ -2730,7 +2730,7 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) int cmpeph(const void *p1, const void *p2) { auto *q1 = (eph_t *)p1, *q2 = (eph_t *)p2; - return q1->ttr.time != q2->ttr.time ? (int)(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); + return q1->ttr.time != q2->ttr.time ? static_cast(q1->ttr.time - q2->ttr.time) : (q1->toe.time != q2->toe.time ? static_cast(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); } @@ -2756,7 +2756,7 @@ void uniqeph(nav_t *nav) } nav->n = j + 1; - if (!(nav_eph = (eph_t *)realloc(nav->eph, sizeof(eph_t) * nav->n))) + if (!(nav_eph = static_cast(realloc(nav->eph, sizeof(eph_t) * nav->n)))) { trace(1, "uniqeph malloc error n=%d\n", nav->n); free(nav->eph); @@ -2775,7 +2775,7 @@ void uniqeph(nav_t *nav) int cmpgeph(const void *p1, const void *p2) { auto *q1 = (geph_t *)p1, *q2 = (geph_t *)p2; - return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? (int)(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); + return q1->tof.time != q2->tof.time ? static_cast(q1->tof.time - q2->tof.time) : (q1->toe.time != q2->toe.time ? static_cast(q1->toe.time - q2->toe.time) : q1->sat - q2->sat); } @@ -2802,7 +2802,7 @@ void uniqgeph(nav_t *nav) } nav->ng = j + 1; - if (!(nav_geph = (geph_t *)realloc(nav->geph, sizeof(geph_t) * nav->ng))) + if (!(nav_geph = static_cast(realloc(nav->geph, sizeof(geph_t) * nav->ng)))) { trace(1, "uniqgeph malloc error ng=%d\n", nav->ng); free(nav->geph); @@ -2821,7 +2821,7 @@ void uniqgeph(nav_t *nav) int cmpseph(const void *p1, const void *p2) { auto *q1 = (seph_t *)p1, *q2 = (seph_t *)p2; - return q1->tof.time != q2->tof.time ? (int)(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? (int)(q1->t0.time - q2->t0.time) : q1->sat - q2->sat); + return q1->tof.time != q2->tof.time ? static_cast(q1->tof.time - q2->tof.time) : (q1->t0.time != q2->t0.time ? static_cast(q1->t0.time - q2->t0.time) : q1->sat - q2->sat); } @@ -2847,7 +2847,7 @@ void uniqseph(nav_t *nav) } nav->ns = j + 1; - if (!(nav_seph = (seph_t *)realloc(nav->seph, sizeof(seph_t) * nav->ns))) + if (!(nav_seph = static_cast(realloc(nav->seph, sizeof(seph_t) * nav->ns)))) { trace(1, "uniqseph malloc error ns=%d\n", nav->ns); free(nav->seph); @@ -2893,8 +2893,8 @@ int cmpobs(const void *p1, const void *p2) auto *q1 = (obsd_t *)p1, *q2 = (obsd_t *)p2; double tt = timediff(q1->time, q2->time); if (fabs(tt) > DTTOL) return tt < 0 ? -1 : 1; - if (q1->rcv != q2->rcv) return (int)q1->rcv - (int)q2->rcv; - return (int)q1->sat - (int)q2->sat; + if (q1->rcv != q2->rcv) return static_cast(q1->rcv) - static_cast(q2->rcv); + return static_cast(q1->sat) - static_cast(q2->sat); } @@ -2965,12 +2965,12 @@ int readnav(const char *file, nav_t *nav) 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {}, {}, 0.0, 0.0}; geph_t geph0 = {0, 0, 0, 0, 0, 0, {0, 0}, {0, 0}, {}, {}, {}, 0.0, 0.0, 0.0}; char buff[4096], *p; - long toe_time, tof_time, toc_time, ttr_time; + int32_t toe_time, tof_time, toc_time, ttr_time; int i, sat, prn; trace(3, "loadnav: file=%s\n", file); - if (!(fp = fopen(file, "r"))) return 0; + if (!(fp = fopen(file, "re"))) return 0; while (fgets(buff, sizeof(buff), fp)) { @@ -2997,7 +2997,7 @@ int readnav(const char *file, nav_t *nav) nav->geph[prn - 1].sat = sat; toe_time = tof_time = 0; sscanf(p + 1, - "%d,%d,%d,%d,%d,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," + "%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," "%lf,%lf,%lf,%lf", &nav->geph[prn - 1].iode, &nav->geph[prn - 1].frq, &nav->geph[prn - 1].svh, &nav->geph[prn - 1].sva, &nav->geph[prn - 1].age, @@ -3015,7 +3015,7 @@ int readnav(const char *file, nav_t *nav) nav->eph[sat - 1].sat = sat; toe_time = toc_time = ttr_time = 0; sscanf(p + 1, - "%d,%d,%d,%d,%ld,%ld,%ld,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," + "%d,%d,%d,%d,%d,%d,%d,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf," "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d,%d", &nav->eph[sat - 1].iode, &nav->eph[sat - 1].iodc, &nav->eph[sat - 1].sva, &nav->eph[sat - 1].svh, @@ -3046,7 +3046,7 @@ int savenav(const char *file, const nav_t *nav) trace(3, "savenav: file=%s\n", file); - if (!(fp = fopen(file, "w"))) return 0; + if (!(fp = fopen(file, "we"))) return 0; for (i = 0; i < MAXSAT; i++) { @@ -3057,8 +3057,8 @@ int savenav(const char *file, const nav_t *nav) "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%d,%d\n", id, nav->eph[i].iode, nav->eph[i].iodc, nav->eph[i].sva, - nav->eph[i].svh, (int)nav->eph[i].toe.time, - (int)nav->eph[i].toc.time, (int)nav->eph[i].ttr.time, + nav->eph[i].svh, static_cast(nav->eph[i].toe.time), + static_cast(nav->eph[i].toc.time), static_cast(nav->eph[i].ttr.time), nav->eph[i].A, nav->eph[i].e, nav->eph[i].i0, nav->eph[i].OMG0, nav->eph[i].omg, nav->eph[i].M0, nav->eph[i].deln, nav->eph[i].OMGd, nav->eph[i].idot, nav->eph[i].crc, nav->eph[i].crs, nav->eph[i].cuc, @@ -3074,8 +3074,8 @@ int savenav(const char *file, const nav_t *nav) "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," "%.14E,%.14E,%.14E,%.14E,%.14E,%.14E\n", id, nav->geph[i].iode, nav->geph[i].frq, nav->geph[i].svh, - nav->geph[i].sva, nav->geph[i].age, (int)nav->geph[i].toe.time, - (int)nav->geph[i].tof.time, + nav->geph[i].sva, nav->geph[i].age, static_cast(nav->geph[i].toe.time), + static_cast(nav->geph[i].tof.time), nav->geph[i].pos[0], nav->geph[i].pos[1], nav->geph[i].pos[2], nav->geph[i].vel[0], nav->geph[i].vel[1], nav->geph[i].vel[2], nav->geph[i].acc[0], nav->geph[i].acc[1], nav->geph[i].acc[2], @@ -3187,8 +3187,8 @@ void traceswap(void) rtk_lock(&lock_trace); - if ((int)(time2gpst(time, nullptr) / INT_SWAP_TRAC) == - (int)(time2gpst(time_trace, nullptr) / INT_SWAP_TRAC)) + if (static_cast(time2gpst(time, nullptr) / INT_SWAP_TRAC) == + static_cast(time2gpst(time_trace, nullptr) / INT_SWAP_TRAC)) { rtk_unlock(&lock_trace); return; @@ -3202,7 +3202,7 @@ void traceswap(void) } if (fp_trace) fclose(fp_trace); - if (!(fp_trace = fopen(path, "w"))) + if (!(fp_trace = fopen(path, "we"))) { fp_trace = stderr; } @@ -3216,7 +3216,7 @@ void traceopen(const char *file) char path[1024]; reppath(file, path, time, "", ""); - if (!*path || !(fp_trace = fopen(path, "w"))) fp_trace = stderr; + if (!*path || !(fp_trace = fopen(path, "we"))) fp_trace = stderr; if (strlen(file) < 1025) strcpy(file_trace, file); else @@ -3447,7 +3447,7 @@ void createdir(const char *path) /* replace string ------------------------------------------------------------*/ int repstr(char *str, const char *pat, const char *rep) { - int len = (int)strlen(pat); + int len = static_cast(strlen(pat)); char buff[1024], *p, *q, *r; for (p = str, r = buff; *p; p = q + len) @@ -3512,13 +3512,13 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, { time2epoch(time, ep); ep0[0] = ep[0]; - dow = (int)floor(time2gpst(time, &week) / 86400.0); - doy = (int)floor(timediff(time, epoch2time(ep0)) / 86400.0) + 1; - sprintf(rep, "%02d", ((int)ep[3] / 3) * 3); + dow = static_cast(floor(time2gpst(time, &week) / 86400.0)); + doy = static_cast(floor(timediff(time, epoch2time(ep0)) / 86400.0)) + 1; + sprintf(rep, "%02d", (static_cast(ep[3]) / 3) * 3); stat |= repstr(rpath, "%ha", rep); - sprintf(rep, "%02d", ((int)ep[3] / 6) * 6); + sprintf(rep, "%02d", (static_cast(ep[3]) / 6) * 6); stat |= repstr(rpath, "%hb", rep); - sprintf(rep, "%02d", ((int)ep[3] / 12) * 12); + sprintf(rep, "%02d", (static_cast(ep[3]) / 12) * 12); stat |= repstr(rpath, "%hc", rep); sprintf(rep, "%04.0f", ep[0]); stat |= repstr(rpath, "%Y", rep); @@ -3540,9 +3540,9 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, stat |= repstr(rpath, "%W", rep); sprintf(rep, "%d", dow); stat |= repstr(rpath, "%D", rep); - sprintf(rep, "%c", 'a' + (int)ep[3]); + sprintf(rep, "%c", 'a' + static_cast(ep[3])); stat |= repstr(rpath, "%H", rep); - sprintf(rep, "%02d", ((int)ep[4] / 15) * 15); + sprintf(rep, "%02d", (static_cast(ep[4]) / 15) * 15); stat |= repstr(rpath, "%t", rep); } else if (strstr(rpath, "%ha") || strstr(rpath, "%hb") || strstr(rpath, "%hc") || @@ -3593,7 +3593,7 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, while (timediff(time, te) <= 0.0 && n < nmax) { reppath(path, rpath[n], time, rov, base); - if (n == 0 || strcmp(rpath[n], rpath[n - 1])) n++; + if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) n++; time = timeadd(time, tint); } for (i = 0; i < n; i++) trace(3, "reppaths: rpath=%s\n", rpath[i]); @@ -3646,9 +3646,9 @@ double satwavelen(int sat, int frq, const nav_t *nav) return SPEED_OF_LIGHT / FREQ2; /* L2 */ if (frq == 2) return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ - else if (frq == 3) + if (frq == 3) return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ - else if (frq == 4) + if (frq == 4) return SPEED_OF_LIGHT / FREQ7; /* E5b */ else if (frq == 5) return SPEED_OF_LIGHT / FREQ8; /* E5a+b */ @@ -3881,7 +3881,7 @@ double tropmodel(gtime_t time __attribute__((unused)), const double *pos, const double interpc(const double coef[], double lat) { - int i = (int)(lat / 15.0); + int i = static_cast(lat / 15.0); if (i < 1) return coef[0]; if (i > 4) @@ -3994,7 +3994,7 @@ double tropmapf(gtime_t time, const double pos[], const double azel[], double interpvar(double ang, const double *var) { double a = ang / 5.0; /* ang=0-90 */ - int i = (int)a; + int i = static_cast(a); if (i < 0) return var[0]; if (i >= 18) @@ -4307,8 +4307,8 @@ int expath(const char *path, char *paths[], int nmax) if (*(d->d_name) == '.') continue; sprintf(s1, "^%s$", d->d_name); sprintf(s2, "^%s$", file); - for (p = s1; *p; p++) *p = (char)tolower((int)*p); - for (p = s2; *p; p++) *p = (char)tolower((int)*p); + for (p = s1; *p; p++) *p = static_cast(tolower(static_cast(*p))); + for (p = s2; *p; p++) *p = static_cast(tolower(static_cast(*p))); for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(nullptr, "*", &r)) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index 20dac4267..e33f770e6 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -151,7 +151,7 @@ int rtkopenstat(const char *file, int level) reppath(file, path, time, "", ""); - if (!(fp_stat = fopen(path, "w"))) + if (!(fp_stat = fopen(path, "we"))) { trace(1, "rtkopenstat: file open error path=%s\n", path); return 0; @@ -301,8 +301,8 @@ void swapsolstat(void) gtime_t time = utc2gpst(timeget()); char path[1024]; - if ((int)(time2gpst(time, nullptr) / INT_SWAP_STAT) == - (int)(time2gpst(time_stat, nullptr) / INT_SWAP_STAT)) + if (static_cast(time2gpst(time, nullptr) / INT_SWAP_STAT) == + static_cast(time2gpst(time_stat, nullptr) / INT_SWAP_STAT)) { return; } @@ -314,7 +314,7 @@ void swapsolstat(void) } if (fp_stat) fclose(fp_stat); - if (!(fp_stat = fopen(path, "w"))) + if (!(fp_stat = fopen(path, "we"))) { trace(2, "swapsolstat: file open error path=%s\n", path); return; @@ -795,7 +795,7 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv) setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]); /* save slip and half-cycle valid flag */ - rtk->ssat[sat - 1].slip[f] |= (unsigned char)slip; + rtk->ssat[sat - 1].slip[f] |= static_cast(slip); rtk->ssat[sat - 1].half[f] = (obs[i].LLI[f] & 2) ? 0 : 1; } } @@ -923,7 +923,7 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, /* reset phase-bias if instantaneous AR or expire obs outage counter */ for (i = 1; i <= MAXSAT; i++) { - reset = ++rtk->ssat[i - 1].outc[f] > (unsigned int)rtk->opt.maxout; + reset = ++rtk->ssat[i - 1].outc[f] > static_cast(rtk->opt.maxout); if (rtk->opt.modear == ARMODE_INST && rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) { @@ -1786,7 +1786,7 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) trace(4, "N(2)="); tracemat(4, b + nb, 1, nb, 10, 3); - rtk->sol.ratio = s[0] > 0 ? (float)(s[1] / s[0]) : 0.0f; + rtk->sol.ratio = s[0] > 0 ? static_cast(s[1] / s[0]) : 0.0f; if (rtk->sol.ratio > 999.9) rtk->sol.ratio = 999.9f; /* validation by popular ratio-test */ @@ -2077,22 +2077,22 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->xa[i]; - rtk->sol.qr[i] = (float)rtk->Pa[i + i * rtk->na]; + rtk->sol.qr[i] = static_cast(rtk->Pa[i + i * rtk->na]); } - rtk->sol.qr[3] = (float)rtk->Pa[1]; - rtk->sol.qr[4] = (float)rtk->Pa[1 + 2 * rtk->na]; - rtk->sol.qr[5] = (float)rtk->Pa[2]; + rtk->sol.qr[3] = static_cast(rtk->Pa[1]); + rtk->sol.qr[4] = static_cast(rtk->Pa[1 + 2 * rtk->na]); + rtk->sol.qr[5] = static_cast(rtk->Pa[2]); } else { for (i = 0; i < 3; i++) { rtk->sol.rr[i] = rtk->x[i]; - rtk->sol.qr[i] = (float)rtk->P[i + i * rtk->nx]; + rtk->sol.qr[i] = static_cast(rtk->P[i + i * rtk->nx]); } - rtk->sol.qr[3] = (float)rtk->P[1]; - rtk->sol.qr[4] = (float)rtk->P[1 + 2 * rtk->nx]; - rtk->sol.qr[5] = (float)rtk->P[2]; + rtk->sol.qr[3] = static_cast(rtk->P[1]); + rtk->sol.qr[4] = static_cast(rtk->P[1 + 2 * rtk->nx]); + rtk->sol.qr[5] = static_cast(rtk->P[2]); rtk->nfix = 0; } for (i = 0; i < n; i++) @@ -2321,7 +2321,7 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) errmsg(rtk, "base station position error (%s)\n", msg); return 0; } - rtk->sol.age = (float)timediff(rtk->sol.time, solb.time); + rtk->sol.age = static_cast(timediff(rtk->sol.time, solb.time)); if (fabs(rtk->sol.age) > TTOL_MOVEB) { @@ -2335,7 +2335,7 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) } else { - rtk->sol.age = (float)timediff(obs[0].time, obs[nu].time); + rtk->sol.age = static_cast(timediff(obs[0].time, obs[nu].time)); if (fabs(rtk->sol.age) > opt->maxtdiff) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 3fafef550..062597f41 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -393,7 +393,7 @@ void decodefile(rtksvr_t *svr, int index) rtksvrunlock(svr); return; } - strncpy(file, (char *)svr->buff[index], nb - 2); + strncpy(file, reinterpret_cast(svr->buff[index]), nb - 2); file[nb - 2] = '\0'; svr->nb[index] = 0; @@ -446,7 +446,7 @@ void decodefile(rtksvr_t *svr, int index) /* rtk server thread ---------------------------------------------------------*/ void *rtksvrthread(void *arg) { - auto *svr = (rtksvr_t *)arg; + auto *svr = static_cast(arg); obs_t obs; obsd_t data[MAXOBS * 2]; double tt; @@ -518,14 +518,14 @@ void *rtksvrthread(void *arg) if (svr->rtk.sol.stat != SOLQ_NONE) { /* adjust current time */ - tt = (int)(tickget() - tick) / 1000.0 + DTTOL; + tt = static_cast(tickget() - tick) / 1000.0 + DTTOL; timeset(gpst2utc(timeadd(svr->rtk.sol.time, tt))); /* write solution */ writesol(svr, i); } /* if cpu overload, inclement obs outage counter and break */ - if ((int)(tickget() - tick) >= svr->cycle) + if (static_cast(tickget() - tick) >= svr->cycle) { svr->prcout += fobs[0] - i - 1; #if 0 /* omitted v.2.4.1 */ @@ -539,7 +539,7 @@ void *rtksvrthread(void *arg) writesol(svr, 0); } /* send nmea request to base/nrtk input stream */ - if (svr->nmeacycle > 0 && (int)(tick - ticknmea) >= svr->nmeacycle) + if (svr->nmeacycle > 0 && static_cast(tick - ticknmea) >= svr->nmeacycle) { if (svr->stream[1].state == 1) { @@ -554,7 +554,7 @@ void *rtksvrthread(void *arg) } ticknmea = tick; } - if ((cputime = (int)(tickget() - tick)) > 0) svr->cputime = cputime; + if ((cputime = static_cast(tickget() - tick)) > 0) svr->cputime = cputime; /* sleep until next cycle */ sleepms(svr->cycle - cputime); @@ -620,12 +620,12 @@ int rtksvrinit(rtksvr_t *svr) for (i = 0; i < 3; i++) svr->files[i][0] = '\0'; svr->moni = nullptr; svr->tick = 0; - svr->thread = 0; + svr->thread = 0; // NOLINT svr->cputime = svr->prcout = 0; - if (!(svr->nav.eph = (eph_t *)malloc(sizeof(eph_t) * MAXSAT * 2)) || - !(svr->nav.geph = (geph_t *)malloc(sizeof(geph_t) * NSATGLO * 2)) || - !(svr->nav.seph = (seph_t *)malloc(sizeof(seph_t) * NSATSBS * 2))) + if (!(svr->nav.eph = static_cast(malloc(sizeof(eph_t) * MAXSAT * 2))) || + !(svr->nav.geph = static_cast(malloc(sizeof(geph_t) * NSATGLO * 2))) || + !(svr->nav.seph = static_cast(malloc(sizeof(seph_t) * NSATSBS * 2)))) { tracet(1, "rtksvrinit: malloc error\n"); return 0; @@ -640,7 +640,7 @@ int rtksvrinit(rtksvr_t *svr) for (i = 0; i < 3; i++) for (j = 0; j < MAXOBSBUF; j++) { - if (!(svr->obs[i][j].data = (obsd_t *)malloc(sizeof(obsd_t) * MAXOBS))) + if (!(svr->obs[i][j].data = static_cast(malloc(sizeof(obsd_t) * MAXOBS)))) { tracet(1, "rtksvrinit: malloc error\n"); return 0; @@ -760,8 +760,8 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, for (i = 0; i < 3; i++) { /* input/log streams */ svr->nb[i] = svr->npb[i] = 0; - if (!(svr->buff[i] = (unsigned char *)malloc(buffsize)) || - !(svr->pbuf[i] = (unsigned char *)malloc(buffsize))) + if (!(svr->buff[i] = static_cast(malloc(buffsize))) || + !(svr->pbuf[i] = static_cast(malloc(buffsize)))) { tracet(1, "rtksvrstart: malloc error\n"); return 0; @@ -782,7 +782,7 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, } for (i = 0; i < 2; i++) { /* output peek buffer */ - if (!(svr->sbuf[i] = (unsigned char *)malloc(buffsize))) + if (!(svr->sbuf[i] = static_cast(malloc(buffsize)))) { tracet(1, "rtksvrstart: malloc error\n"); return 0; @@ -979,7 +979,7 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat, el[i] = svr->rtk.ssat[sat[i] - 1].azel[1]; for (j = 0; j < NFREQ; j++) { - snr[i][j] = (int)(svr->obs[rcv][0].data[i].SNR[j] * 0.25); + snr[i][j] = static_cast(svr->obs[rcv][0].data[i].SNR[j] * 0.25); } if (svr->rtk.sol.stat == SOLQ_NONE || svr->rtk.sol.stat == SOLQ_SINGLE) { diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index 52aa5b0c6..2341a30d8 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -148,7 +148,7 @@ int decode_sbstype2(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype2:\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 16, 2)) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 16, 2))) return 0; type = getbitu(msg->msg, 8, 6); iodf = getbitu(msg->msg, 14, 2); @@ -209,7 +209,7 @@ int decode_sbstype7(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype7\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 18, 2)) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 18, 2))) return 0; sbssat->tlat = getbitu(msg->msg, 14, 4); @@ -234,7 +234,7 @@ int decode_sbstype9(const sbsmsg_t *msg, nav_t *nav) trace(2, "invalid prn in sbas type 9: prn=%3d\n", msg->prn); return 0; } - t = (int)getbitu(msg->msg, 22, 13) * 16 - (int)msg->tow % 86400; + t = static_cast(getbitu(msg->msg, 22, 13)) * 16 - msg->tow % 86400; if (t <= -43200) t += 86400; else if (t > 43200) @@ -292,7 +292,7 @@ int decode_sbstype18(const sbsmsg_t *msg, sbsion_t *sbsion) else return 0; - sbsion[band].iodi = (short)getbitu(msg->msg, 22, 2); + sbsion[band].iodi = static_cast(getbitu(msg->msg, 22, 2)); for (i = 1, n = 0; i <= 201; i++) { @@ -355,7 +355,7 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat) } sbssat->sat[n - 1].lcorr.daf0 = getbits(msg->msg, p + 47, 11) * TWO_N31; sbssat->sat[n - 1].lcorr.daf1 = getbits(msg->msg, p + 82, 8) * TWO_N39; - t = (int)getbitu(msg->msg, p + 90, 13) * 16 - (int)msg->tow % 86400; + t = static_cast(getbitu(msg->msg, p + 90, 13)) * 16 - msg->tow % 86400; if (t <= -43200) t += 86400; else if (t > 43200) @@ -374,13 +374,13 @@ int decode_longcorrh(const sbsmsg_t *msg, int p, sbssat_t *sbssat) if (getbitu(msg->msg, p, 1) == 0) { /* vel code=0 */ - if (sbssat->iodp == (int)getbitu(msg->msg, p + 103, 2)) + if (sbssat->iodp == static_cast(getbitu(msg->msg, p + 103, 2))) { return decode_longcorr0(msg, p + 1, sbssat) && decode_longcorr0(msg, p + 52, sbssat); } } - else if (sbssat->iodp == (int)getbitu(msg->msg, p + 104, 2)) + else if (sbssat->iodp == static_cast(getbitu(msg->msg, p + 104, 2))) { return decode_longcorr1(msg, p + 1, sbssat); } @@ -395,7 +395,7 @@ int decode_sbstype24(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype24:\n"); - if (sbssat->iodp != (int)getbitu(msg->msg, 110, 2)) return 0; /* check IODP */ + if (sbssat->iodp != static_cast(getbitu(msg->msg, 110, 2))) return 0; /* check IODP */ blk = getbitu(msg->msg, 112, 2); iodf = getbitu(msg->msg, 114, 2); @@ -430,7 +430,7 @@ int decode_sbstype26(const sbsmsg_t *msg, sbsion_t *sbsion) trace(4, "decode_sbstype26:\n"); - if (band > MAXBAND || sbsion[band].iodi != (int)getbitu(msg->msg, 217, 2)) return 0; + if (band > MAXBAND || sbsion[band].iodi != static_cast(getbitu(msg->msg, 217, 2))) return 0; block = getbitu(msg->msg, 18, 4); @@ -529,7 +529,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, trace(3, "readmsgs: file=%s sel=%d\n", file, sel); - if (!(fp = fopen(file, "r"))) + if (!(fp = fopen(file, "re"))) { trace(2, "sbas message file open error: %s\n", file); return; @@ -575,7 +575,7 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, if (sbs->n >= sbs->nmax) { sbs->nmax = sbs->nmax == 0 ? 1024 : sbs->nmax * 2; - if (!(sbs_msgs = (sbsmsg_t *)realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t)))) + if (!(sbs_msgs = static_cast(realloc(sbs->msgs, sbs->nmax * sizeof(sbsmsg_t))))) { trace(1, "readsbsmsg malloc error: nmax=%d\n", sbs->nmax); free(sbs->msgs); @@ -587,12 +587,12 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, sbs->msgs = sbs_msgs; } sbs->msgs[sbs->n].week = week; - sbs->msgs[sbs->n].tow = (int)(tow + 0.5); + sbs->msgs[sbs->n].tow = static_cast(tow + 0.5); sbs->msgs[sbs->n].prn = prn; for (i = 0; i < 29; i++) sbs->msgs[sbs->n].msg[i] = 0; for (i = 0; *(p - 1) && *p && i < 29; p += 2, i++) { - if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = (unsigned char)b; + if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = static_cast(b); } sbs->msgs[sbs->n++].msg[28] &= 0xC0; } @@ -633,7 +633,7 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < MAXEXFILE; i++) { - if (!(efiles[i] = (char *)malloc(1024))) + if (!(efiles[i] = static_cast(malloc(1024)))) { for (i--; i >= 0; i--) free(efiles[i]); return 0; @@ -645,8 +645,8 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < n; i++) { if (!(ext = strrchr(efiles[i], '.'))) continue; - if (strcmp(ext, ".sbs") && strcmp(ext, ".SBS") && - strcmp(ext, ".ems") && strcmp(ext, ".EMS")) continue; + if (strcmp(ext, ".sbs") != 0 && strcmp(ext, ".SBS") && + strcmp(ext, ".ems") != 0 && strcmp(ext, ".EMS") != 0) continue; readmsgs(efiles[i], sel, ts, te, sbs); } @@ -702,38 +702,38 @@ void searchigp(gtime_t time __attribute__((unused)), const double *pos, const sb if (lon >= 180.0) lon -= 360.0; if (-55.0 <= lat && lat < 55.0) { - latp[0] = (int)floor(lat / 5.0) * 5; + latp[0] = static_cast(floor(lat / 5.0)) * 5; latp[1] = latp[0] + 5; - lonp[0] = lonp[1] = (int)floor(lon / 5.0) * 5; + lonp[0] = lonp[1] = static_cast(floor(lon / 5.0)) * 5; lonp[2] = lonp[3] = lonp[0] + 5; *x = (lon - lonp[0]) / 5.0; *y = (lat - latp[0]) / 5.0; } else { - latp[0] = (int)floor((lat - 5.0) / 10.0) * 10 + 5; + latp[0] = static_cast(floor((lat - 5.0) / 10.0)) * 10 + 5; latp[1] = latp[0] + 10; - lonp[0] = lonp[1] = (int)floor(lon / 10.0) * 10; + lonp[0] = lonp[1] = static_cast(floor(lon / 10.0)) * 10; lonp[2] = lonp[3] = lonp[0] + 10; *x = (lon - lonp[0]) / 10.0; *y = (lat - latp[0]) / 10.0; if (75.0 <= lat && lat < 85.0) { - lonp[1] = (int)floor(lon / 90.0) * 90; + lonp[1] = static_cast(floor(lon / 90.0)) * 90; lonp[3] = lonp[1] + 90; } else if (-85.0 <= lat && lat < -75.0) { - lonp[0] = (int)floor((lon - 50.0) / 90.0) * 90 + 40; + lonp[0] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; lonp[2] = lonp[0] + 90; } else if (lat >= 85.0) { - for (i = 0; i < 4; i++) lonp[i] = (int)floor(lon / 90.0) * 90; + for (i = 0; i < 4; i++) lonp[i] = static_cast(floor(lon / 90.0)) * 90; } else if (lat < -85.0) { - for (i = 0; i < 4; i++) lonp[i] = (int)floor((lon - 50.0) / 90.0) * 90 + 40; + for (i = 0; i < 4; i++) lonp[i] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; } } for (i = 0; i < 4; i++) @@ -864,7 +864,7 @@ void getmet(double lat, double *met) for (i = 0; i < 10; i++) met[i] = metprm[4][i]; else { - j = (int)(lat / 15.0); + j = static_cast(lat / 15.0); a = (lat - j * 15.0) / 15.0; for (i = 0; i < 10; i++) met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i]; } @@ -1049,14 +1049,14 @@ int sbsdecodemsg(gtime_t time, int prn, const unsigned int *words, if (time.time == 0) return 0; tow = time2gpst(time, &sbsmsg->week); - sbsmsg->tow = (int)(tow + DTTOL); + sbsmsg->tow = static_cast(tow + DTTOL); sbsmsg->prn = prn; for (i = 0; i < 7; i++) for (j = 0; j < 4; j++) { - sbsmsg->msg[i * 4 + j] = (unsigned char)(words[i] >> ((3 - j) * 8)); + sbsmsg->msg[i * 4 + j] = static_cast(words[i] >> ((3 - j) * 8)); } - sbsmsg->msg[28] = (unsigned char)(words[7] >> 18) & 0xC0; + sbsmsg->msg[28] = static_cast(words[7] >> 18) & 0xC0; for (i = 28; i > 0; i--) f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2); f[0] = sbsmsg->msg[0] >> 6; diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index 587067bb7..ddafc248b 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -51,7 +51,7 @@ * *----------------------------------------------------------------------------*/ -#include +#include #include "rtklib_solution.h" #include "rtklib_rtkcmn.h" #include "rtklib_rtksvr.h" @@ -88,7 +88,7 @@ const char *opt2sep(const solopt_t *opt) /* separate fields -----------------------------------------------------------*/ int tonum(char *buff, const char *sep, double *v) { - int n, len = (int)strlen(sep); + int n, len = static_cast(strlen(sep)); char *p, *q; for (p = buff, n = 0; n < MAXFIELD; p = q + len) @@ -140,12 +140,12 @@ void soltocov(const sol_t *sol, double *P) /* covariance to solution ----------------------------------------------------*/ void covtosol(const double *P, sol_t *sol) { - sol->qr[0] = (float)P[0]; /* xx or ee */ - sol->qr[1] = (float)P[4]; /* yy or nn */ - sol->qr[2] = (float)P[8]; /* zz or uu */ - sol->qr[3] = (float)P[1]; /* xy or en */ - sol->qr[4] = (float)P[5]; /* yz or nu */ - sol->qr[5] = (float)P[2]; /* zx or ue */ + sol->qr[0] = static_cast(P[0]); /* xx or ee */ + sol->qr[1] = static_cast(P[4]); /* yy or nn */ + sol->qr[2] = static_cast(P[8]); /* zz or uu */ + sol->qr[3] = static_cast(P[1]); /* xy or en */ + sol->qr[4] = static_cast(P[5]); /* yz or nu */ + sol->qr[5] = static_cast(P[2]); /* zx or ue */ } @@ -364,7 +364,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) strcpy(s, "\t"); else if (*opt->sep) strcpy(s, opt->sep); - len = (int)strlen(s); + len = static_cast(strlen(s)); /* yyyy/mm/dd hh:mm:ss or yyyy mm dd hh:mm:ss */ if (sscanf(buff, "%lf/%lf/%lf %lf:%lf:%lf", v, v + 1, v + 2, v + 3, v + 4, v + 5) >= 6) @@ -383,7 +383,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) *time = utc2gpst(timeadd(*time, -9 * 3600.0)); } if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr; - for (p++; isdigit((int)*p) || *p == '.';) p++; + for (p++; isdigit(static_cast(*p)) || *p == '.';) p++; return p + len; } if (opt->posf == SOLF_GSIF) @@ -394,7 +394,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) } *time = timeadd(epoch2time(v), -12.0 * 3600.0); if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr; - for (p++; isdigit((int)*p) || *p == '.';) p++; + for (p++; isdigit(static_cast(*p)) || *p == '.';) p++; return p + len; } /* wwww ssss */ @@ -406,7 +406,7 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) } if (n >= 2 && 0.0 <= v[0] && v[0] <= 3000.0 && 0.0 <= v[1] && v[1] < 604800.0) { - *time = gpst2time((int)v[0], v[1]); + *time = gpst2time(static_cast(v[0]), v[1]); return p; } return nullptr; @@ -428,8 +428,8 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) { sol->rr[j] = val[i++]; /* xyz */ } - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) sol->stat = static_cast(val[i++]); + if (i < n) sol->ns = static_cast(val[i++]); if (i + 3 < n) { P[0] = val[i] * val[i]; @@ -449,8 +449,8 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(P, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) sol->age = static_cast(val[i++]); + if (i < n) sol->ratio = static_cast(val[i]); sol->type = 0; /* position type = xyz */ @@ -486,8 +486,8 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) i += 7; } pos2ecef(pos, sol->rr); - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) sol->stat = static_cast(val[i++]); + if (i < n) sol->ns = static_cast(val[i++]); if (i + 3 < n) { Q[4] = val[i] * val[i]; @@ -508,8 +508,8 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) covecef(pos, Q, P); covtosol(P, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) sol->age = static_cast(val[i++]); + if (i < n) sol->ratio = static_cast(val[i]); sol->type = 0; /* position type = xyz */ @@ -533,8 +533,8 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) { sol->rr[j] = val[i++]; /* enu */ } - if (i < n) sol->stat = (unsigned char)val[i++]; - if (i < n) sol->ns = (unsigned char)val[i++]; + if (i < n) sol->stat = static_cast(val[i++]); + if (i < n) sol->ns = static_cast(val[i++]); if (i + 3 < n) { Q[0] = val[i] * val[i]; @@ -554,8 +554,8 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(Q, sol); } - if (i < n) sol->age = (float)val[i++]; - if (i < n) sol->ratio = (float)val[i]; + if (i < n) sol->age = static_cast(val[i++]); + if (i < n) sol->ratio = static_cast(val[i]); sol->type = 1; /* position type = enu */ @@ -682,7 +682,7 @@ void decode_solopt(char *buff, solopt_t *opt) trace(4, "decode_solhead: buff=%s\n", buff); - if (strncmp(buff, COMMENTH, 1) && strncmp(buff, "+", 1)) return; + if (strncmp(buff, COMMENTH, 1) != 0 && strncmp(buff, "+", 1)) return; if (strstr(buff, "GPST")) opt->times = TIMES_GPST; @@ -776,13 +776,13 @@ int inputsol(unsigned char data, gtime_t ts, gtime_t te, double tint, solbuf->nb = 0; /* check disconnect message */ - if (!strcmp((char *)solbuf->buff, MSG_DISCONN)) + if (!strcmp(reinterpret_cast(solbuf->buff), MSG_DISCONN)) { trace(3, "disconnect received\n"); return -1; } /* decode solution */ - if ((stat = decode_sol((char *)solbuf->buff, opt, &sol, solbuf->rb)) > 0) + if ((stat = decode_sol(reinterpret_cast(solbuf->buff), opt, &sol, solbuf->rb)) > 0) { solbuf->time = sol.time; /* update current time */ } @@ -806,7 +806,7 @@ int readsoldata(FILE *fp, gtime_t ts, gtime_t te, double tint, int qflag, while ((c = fgetc(fp)) != EOF) { /* input solution */ - inputsol((unsigned char)c, ts, te, tint, qflag, opt, solbuf); + inputsol(static_cast(c), ts, te, tint, qflag, opt, solbuf); } return solbuf->n > 0; } @@ -830,7 +830,7 @@ int sort_solbuf(solbuf_t *solbuf) if (solbuf->n <= 0) return 0; - if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->n))) + if (!(solbuf_data = static_cast(realloc(solbuf->data, sizeof(sol_t) * solbuf->n)))) { trace(1, "sort_solbuf: memory allocation error\n"); free(solbuf->data); @@ -871,7 +871,7 @@ int readsolt(char *files[], int nfile, gtime_t ts, gtime_t te, for (i = 0; i < nfile; i++) { - if (!(fp = fopen(files[i], "rb"))) + if (!(fp = fopen(files[i], "rbe"))) { trace(1, "readsolt: file open error %s\n", files[i]); continue; @@ -931,7 +931,7 @@ int addsol(solbuf_t *solbuf, const sol_t *sol) if (solbuf->n >= solbuf->nmax) { solbuf->nmax = solbuf->nmax == 0 ? 8192 : solbuf->nmax * 2; - if (!(solbuf_data = (sol_t *)realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax))) + if (!(solbuf_data = static_cast(realloc(solbuf->data, sizeof(sol_t) * solbuf->nmax)))) { trace(1, "addsol: memory allocation error\n"); free(solbuf->data); @@ -985,7 +985,7 @@ void initsolbuf(solbuf_t *solbuf, int cyclic, int nmax) if (cyclic) { if (nmax <= 2) nmax = 2; - if (!(solbuf->data = (sol_t *)malloc(sizeof(sol_t) * nmax))) + if (!(solbuf->data = static_cast(malloc(sizeof(sol_t) * nmax)))) { trace(1, "initsolbuf: memory allocation error\n"); return; @@ -1038,7 +1038,7 @@ int sort_solstat(solstatbuf_t *statbuf) if (statbuf->n <= 0) return 0; - if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) * statbuf->n))) + if (!(statbuf_data = static_cast(realloc(statbuf->data, sizeof(solstat_t) * statbuf->n)))) { trace(1, "sort_solstat: memory allocation error\n"); free(statbuf->data); @@ -1084,18 +1084,18 @@ int decode_solstat(char *buff, solstat_t *stat) } *stat = stat0; stat->time = gpst2time(week, tow); - stat->sat = (unsigned char)sat; - stat->frq = (unsigned char)frq; - stat->az = (float)(az * D2R); - stat->el = (float)(el * D2R); - stat->resp = (float)resp; - stat->resc = (float)resc; - stat->flag = (unsigned char)((vsat << 5) + (slip << 3) + fix); - stat->snr = (unsigned char)(snr * 4.0 + 0.5); - stat->lock = (unsigned short)lock; - stat->outc = (unsigned short)outc; - stat->slipc = (unsigned short)slipc; - stat->rejc = (unsigned short)rejc; + stat->sat = static_cast(sat); + stat->frq = static_cast(frq); + stat->az = static_cast(az * D2R); + stat->el = static_cast(el * D2R); + stat->resp = static_cast(resp); + stat->resc = static_cast(resc); + stat->flag = static_cast((vsat << 5) + (slip << 3) + fix); + stat->snr = static_cast(snr * 4.0 + 0.5); + stat->lock = static_cast(lock); + stat->outc = static_cast(outc); + stat->slipc = static_cast(slipc); + stat->rejc = static_cast(rejc); return 1; } @@ -1110,8 +1110,8 @@ void addsolstat(solstatbuf_t *statbuf, const solstat_t *stat) if (statbuf->n >= statbuf->nmax) { statbuf->nmax = statbuf->nmax == 0 ? 8192 : statbuf->nmax * 2; - if (!(statbuf_data = (solstat_t *)realloc(statbuf->data, sizeof(solstat_t) * - statbuf->nmax))) + if (!(statbuf_data = static_cast(realloc(statbuf->data, sizeof(solstat_t) * + statbuf->nmax)))) { trace(1, "addsolstat: memory allocation error\n"); free(statbuf->data); @@ -1174,7 +1174,7 @@ int readsolstatt(char *files[], int nfile, gtime_t ts, gtime_t te, for (i = 0; i < nfile; i++) { sprintf(path, "%s.stat", files[i]); - if (!(fp = fopen(path, "r"))) + if (!(fp = fopen(path, "re"))) { trace(1, "readsolstatt: file open error %s\n", path); continue; @@ -1205,7 +1205,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol, const solopt_t *opt) { const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outecef:\n"); @@ -1214,7 +1214,7 @@ int outecef(unsigned char *buff, const char *s, const sol_t *sol, sol->ns, sep, SQRT_SOL(sol->qr[0]), sep, SQRT_SOL(sol->qr[1]), sep, SQRT_SOL(sol->qr[2]), sep, sqvar(sol->qr[3]), sep, sqvar(sol->qr[4]), sep, sqvar(sol->qr[5]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1224,7 +1224,7 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, { double pos[3], dms1[3], dms2[3], P[9], Q[9]; const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outpos :\n"); @@ -1249,7 +1249,7 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[2]), sep, sqvar(Q[5]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1260,7 +1260,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, double pos[3], rr[3], enu[3], P[9], Q[9]; int i; const char *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outenu :\n"); @@ -1273,7 +1273,7 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, s, sep, enu[0], sep, enu[1], sep, enu[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[5]), sep, sqvar(Q[2]), sep, sol->age, sep, sol->ratio); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1283,16 +1283,16 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) static double dirp = 0.0; gtime_t time; double ep[6], pos[3], enuv[3], dms1[3], dms2[3], vel, dir, amag = 0.0; - char *p = (char *)buff, *q, sum, *emag = (char *)"E"; + char *p = reinterpret_cast(buff), *q, sum, *emag = (char *)"E"; trace(3, "outnmea_rmc:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPRMC,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } time = gpst2utc(sol->time); if (time.sec >= 0.995) @@ -1317,11 +1317,11 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) p += sprintf(p, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s", ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir, - ep[2], ep[1], (int)ep[0] % 100, amag, emag, + ep[2], ep[1], static_cast(ep[0]) % 100, amag, emag, sol->stat == SOLQ_DGPS || sol->stat == SOLQ_FLOAT || sol->stat == SOLQ_FIX ? "D" : "A"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1331,16 +1331,16 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) gtime_t time; double h, ep[6], pos[3], dms1[3], dms2[3], dop = 1.0; int solq; - char *p = (char *)buff, *q, sum; + char *p = reinterpret_cast(buff), *q, sum; trace(3, "outnmea_gga:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } for (solq = 0; solq < 8; solq++) if (solq_nmea[solq] == sol->stat) break; @@ -1360,9 +1360,9 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq, sol->ns, dop, pos[2] - h, h, sol->age); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1372,16 +1372,16 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, { double azel[MAXSAT * 2], dop[4]; int i, sat, sys, nsat, prn[MAXSAT]; - char *p = (char *)buff, *q, *s, sum; + char *p = reinterpret_cast(buff), *q, *s, sum; trace(3, "outnmea_gsa:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } /* GPGSA: gps/sbas */ @@ -1458,7 +1458,7 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1468,16 +1468,16 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { double az, el, snr; int i, j, k, n, sat, prn, sys, nmsg, sats[MAXSAT]; - char *p = (char *)buff, *q, *s, sum; + char *p = reinterpret_cast(buff), *q, *s, sum; trace(3, "outnmea_gsv:\n"); if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); - for (q = (char *)buff + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); - return p - (char *)buff; + return p - reinterpret_cast(buff); } /* GPGSV: gps/sbas */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) @@ -1574,7 +1574,7 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1601,7 +1601,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) const char *s8[] = {"off", "continuous", "instantaneous", "fix and hold", ""}; const char *s9[] = {"off", "on", "auto calib", "external calib", ""}; int i; - char *p = (char *)buff; + char *p = reinterpret_cast(buff); trace(3, "outprcopts:\n"); @@ -1660,7 +1660,7 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1], opt->antdel[i][2]); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } @@ -1674,7 +1674,7 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) { const char *s1[] = {"WGS84", "Tokyo"}, *s2[] = {"ellipsoidal", "geodetic"}; const char *s3[] = {"GPST", "UTC ", "JST "}, *sep = opt2sep(opt); - char *p = (char *)buff; + char *p = reinterpret_cast(buff); int timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu); trace(3, "outsolheads:\n"); @@ -1725,7 +1725,7 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) "Q", sep, "ns", sep, "sde(m)", sep, "sdn(m)", sep, "sdu(m)", sep, "sden(m)", sep, "sdnu(m)", sep, "sdue(m)", sep, "age(s)", sep, "ratio"); } - return p - (char *)buff; + return p - reinterpret_cast(buff); } diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 6e50d2f8f..3225a791a 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -53,12 +53,12 @@ #include #include #include -#include +#include #include #include #include #include -#include +#include #include #include #include @@ -90,13 +90,13 @@ serial_t *openserial(const char *path, int mode, char *msg) const speed_t bs[] = { B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400}; - struct termios ios; + struct termios ios{}; int rw = 0; tracet(3, "openserial: path=%s mode=%d\n", path, mode); - if (!(serial = (serial_t *)malloc(sizeof(serial_t)))) return nullptr; + if (!(serial = static_cast(malloc(sizeof(serial_t))))) return nullptr; - if ((p = strchr((char *)path, ':'))) + if ((p = strchr(const_cast(path), ':'))) { strncpy(port, path, p - path); port[p - path] = '\0'; @@ -114,7 +114,7 @@ serial_t *openserial(const char *path, int mode, char *msg) free(serial); return nullptr; } - parity = (char)toupper((int)parity); + parity = static_cast(toupper(static_cast(parity))); // sprintf(dev, "/dev/%s", port); This line triggers a warning. Replaced by: std::string s_aux = "/dev/" + std::string(port); @@ -277,7 +277,7 @@ int openfile_(file_t *file, gtime_t time, char *msg) } else if (file->mode & STR_MODE_W) { /* remove time-tag */ - if ((fp = fopen(tagpath, "rb"))) + if ((fp = fopen(tagpath, "rbe"))) { fclose(fp); if (remove(tagpath) != 0) trace(1, "Error removing file"); @@ -313,7 +313,7 @@ file_t *openfile(const char *path, int mode, char *msg) if (!(mode & (STR_MODE_R | STR_MODE_W))) return nullptr; /* file options */ - for (p = (char *)path; (p = strstr(p, "::")); p += 2) + for (p = const_cast(path); (p = strstr(p, "::")); p += 2) { /* file options */ if (*(p + 2) == 'T') timetag = 1; @@ -327,7 +327,7 @@ file_t *openfile(const char *path, int mode, char *msg) if (start <= 0.0) start = 0.0; if (swapintv <= 0.0) swapintv = 0.0; - if (!(file = (file_t *)malloc(sizeof(file_t)))) return nullptr; + if (!(file = static_cast(malloc(sizeof(file_t))))) return nullptr; file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; if (strlen(path) < MAXSTRPATH) strcpy(file->path, path); @@ -435,11 +435,11 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) { if (file->repmode) { /* slave */ - t = (unsigned int)(tick_master + file->offset); + t = (tick_master + file->offset); } else { /* master */ - t = (unsigned int)((tickget() - file->tick) * file->speed + file->start * 1000.0); + t = static_cast((tickget() - file->tick) * file->speed + file->start * 1000.0); } for (;;) { /* seek file position */ @@ -452,23 +452,23 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) } if (file->repmode || file->speed > 0.0) { - if ((int)(tick - t) < 1) continue; + if (static_cast(tick - t) < 1) continue; } if (!file->repmode) tick_master = tick; - sprintf(msg, "T%+.1fs", (int)tick < 0 ? 0.0 : (int)tick / 1000.0); + sprintf(msg, "T%+.1fs", static_cast(tick) < 0 ? 0.0 : static_cast(tick) / 1000.0); - if ((int)(fpos - file->fpos) >= nmax) + if (static_cast(fpos - file->fpos) >= nmax) { if (fseek(file->fp, fpos, SEEK_SET) != 0) trace(1, "Error fseek"); file->fpos = fpos; return 0; } - nmax = (int)(fpos - file->fpos); + nmax = static_cast(fpos - file->fpos); if (file->repmode || file->speed > 0.0) { - if (fseek(file->fp_tag, -(long)(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek"); + if (fseek(file->fp_tag, -static_cast(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek"); } break; } @@ -480,7 +480,7 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) if (nr <= 0) sprintf(msg, "end"); } tracet(5, "readfile: fp=%d nr=%d fpos=%d\n", file->fp, nr, file->fpos); - return (int)nr; + return nr; } @@ -546,7 +546,7 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) } tracet(5, "writefile: fp=%d ns=%d tick=%5d fpos=%d\n", file->fp, ns, tick, fpos); - return (int)ns; + return static_cast(ns); } @@ -556,7 +556,7 @@ void syncfile(file_t *file1, file_t *file2) if (!file1->fp_tag || !file2->fp_tag) return; file1->repmode = 0; file2->repmode = 1; - file2->offset = (int)(file1->tick_f - file2->tick_f); + file2->offset = static_cast(file1->tick_f - file2->tick_f); } @@ -622,21 +622,21 @@ int setsock(socket_t sock, char *msg) tracet(3, "setsock: sock=%d\n", sock); - if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) == -1 || - setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv)) == -1) + if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1 || + setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, reinterpret_cast(&tv), sizeof(tv)) == -1) { sprintf(msg, "sockopt error: notimeo"); tracet(1, "setsock: setsockopt error 1 sock=%d err=%d\n", sock, errsock()); closesocket(sock); return 0; } - if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, (const char *)&bs, sizeof(bs)) == -1 || - setsockopt(sock, SOL_SOCKET, SO_SNDBUF, (const char *)&bs, sizeof(bs)) == -1) + if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&bs), sizeof(bs)) == -1 || + setsockopt(sock, SOL_SOCKET, SO_SNDBUF, reinterpret_cast(&bs), sizeof(bs)) == -1) { tracet(1, "setsock: setsockopt error 2 sock=%d err=%d bs=%d\n", sock, errsock(), bs); sprintf(msg, "sockopt error: bufsiz"); } - if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&mode, sizeof(mode)) == -1) + if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast(&mode), sizeof(mode)) == -1) { tracet(1, "setsock: setsockopt error 3 sock=%d err=%d\n", sock, errsock()); sprintf(msg, "sockopt error: nodelay"); @@ -687,7 +687,7 @@ int recv_nb(socket_t sock, unsigned char *buff, int n) FD_ZERO(&rs); FD_SET(sock, &rs); if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0; - return recv(sock, (char *)buff, n, 0); + return recv(sock, reinterpret_cast(buff), n, 0); } @@ -699,7 +699,7 @@ int send_nb(socket_t sock, unsigned char *buff, int n) FD_ZERO(&ws); FD_SET(sock, &ws); if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) return 0; - return send(sock, (char *)buff, n, 0); + return send(sock, reinterpret_cast(buff), n, 0); } @@ -714,7 +714,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) tracet(3, "gentcp: type=%d\n", type); /* generate socket */ - if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == (socket_t)-1) + if ((tcp->sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1) { sprintf(msg, "socket error (%d)", errsock()); tracet(1, "gentcp: socket error err=%d\n", errsock()); @@ -738,7 +738,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) setsockopt(tcp->sock, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof(opt)); #endif - if (bind(tcp->sock, (struct sockaddr *)&tcp->addr, sizeof(tcp->addr)) == -1) + if (bind(tcp->sock, reinterpret_cast(&tcp->addr), sizeof(tcp->addr)) == -1) { sprintf(msg, "bind error (%d) : %d", errsock(), tcp->port); tracet(1, "gentcp: bind error port=%d err=%d\n", tcp->port, errsock()); @@ -788,7 +788,7 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg) tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}}; tracet(3, "opentcpsvr: path=%s\n", path); - if (!(tcpsvr = (tcpsvr_t *)malloc(sizeof(tcpsvr_t)))) return nullptr; + if (!(tcpsvr = static_cast(malloc(sizeof(tcpsvr_t))))) return nullptr; *tcpsvr = tcpsvr0; decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) @@ -866,7 +866,7 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) /* accept client connection --------------------------------------------------*/ int accsock(tcpsvr_t *tcpsvr, char *msg) { - struct sockaddr_in addr; + struct sockaddr_in addr{}; socket_t sock; socklen_t len = sizeof(addr); int i, err; @@ -877,7 +877,7 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) if (tcpsvr->cli[i].state == 0) break; if (i >= MAXCLI) return 0; /* too many client */ - if ((sock = accept_nb(tcpsvr->svr.sock, (struct sockaddr *)&addr, &len)) == (socket_t)-1) + if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast(&addr), &len)) == -1) { err = errsock(); sprintf(msg, "accept error (%d)", err); @@ -981,12 +981,12 @@ int consock(tcpcli_t *tcpcli, char *msg) /* wait re-connect */ if (tcpcli->svr.tcon < 0 || (tcpcli->svr.tcon > 0 && - (int)(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon)) + static_cast(tickget() - tcpcli->svr.tdis) < tcpcli->svr.tcon)) { return 0; } /* non-block connect */ - if ((stat = connect_nb(tcpcli->svr.sock, (struct sockaddr *)&tcpcli->svr.addr, + if ((stat = connect_nb(tcpcli->svr.sock, reinterpret_cast(&tcpcli->svr.addr), sizeof(tcpcli->svr.addr))) == -1) { err = errsock(); @@ -1018,7 +1018,7 @@ tcpcli_t *opentcpcli(const char *path, char *msg) tracet(3, "opentcpcli: path=%s\n", path); - if (!(tcpcli = (tcpcli_t *)malloc(sizeof(tcpcli_t)))) return nullptr; + if (!(tcpcli = static_cast(malloc(sizeof(tcpcli_t))))) return nullptr; *tcpcli = tcpcli0; decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpcli->svr.port) < 1) @@ -1062,7 +1062,7 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg) if (tcpcli->svr.state == 2) { /* connect */ if (tcpcli->toinact > 0 && - (int)(tickget() - tcpcli->svr.tact) > tcpcli->toinact) + static_cast(tickget() - tcpcli->svr.tact) > tcpcli->toinact) { sprintf(msg, "timeout"); tracet(2, "waittcpcli: inactive timeout sock=%d\n", tcpcli->svr.sock); @@ -1164,7 +1164,7 @@ int reqntrip_s(ntrip_t *ntrip, char *msg) p += sprintf(p, "STR: %s\r\n", ntrip->str); p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) return 0; tracet(2, "reqntrip_s: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_s: n=%d buff=\n%s\n", p - buff, buff); @@ -1192,12 +1192,12 @@ int reqntrip_c(ntrip_t *ntrip, char *msg) { sprintf(user, "%s:%s", ntrip->user, ntrip->passwd); p += sprintf(p, "Authorization: Basic "); - p += encbase64(p, (unsigned char *)user, strlen(user)); + p += encbase64(p, reinterpret_cast(user), strlen(user)); p += sprintf(p, "\r\n"); } p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, (unsigned char *)buff, p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) return 0; tracet(2, "reqntrip_c: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_c: n=%d buff=\n%s\n", p - buff, buff); @@ -1216,9 +1216,9 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) ntrip->buff[ntrip->nb] = '0'; tracet(5, "rspntrip_s: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff); - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_SVR))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_OK_SVR))) { /* ok */ - q = (char *)ntrip->buff; + q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_SVR); ntrip->nb -= p - q; for (i = 0; i < ntrip->nb; i++) *q++ = *p++; @@ -1227,11 +1227,11 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb); return 1; } - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_ERROR))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_ERROR))) { /* error */ nb = ntrip->nb < MAXSTATMSG ? ntrip->nb : MAXSTATMSG; // strncpy(msg, (char *)ntrip->buff, nb); This line triggers a warning. Replaced by; - std::string s_aux((char *)ntrip->buff); + std::string s_aux(reinterpret_cast(ntrip->buff)); s_aux.resize(nb, '\0'); for (int i = 0; i < nb; i++) msg[i] = s_aux[i]; @@ -1266,9 +1266,9 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) ntrip->buff[ntrip->nb] = '0'; tracet(5, "rspntrip_c: n=%d buff=\n%s\n", ntrip->nb, ntrip->buff); - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_OK_CLI))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_OK_CLI))) { /* ok */ - q = (char *)ntrip->buff; + q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_CLI); ntrip->nb -= p - q; for (i = 0; i < ntrip->nb; i++) *q++ = *p++; @@ -1277,7 +1277,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb); return 1; } - if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_SRCTBL))) + if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_SRCTBL))) { /* source table */ if (!*ntrip->mntpnt) { /* source table request */ @@ -1293,7 +1293,7 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) ntrip->state = 0; discontcp(&ntrip->tcp->svr, ntrip->tcp->tirecon); } - else if ((p = strstr((char *)ntrip->buff, NTRIP_RSP_HTTP))) + else if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_HTTP))) { /* http response */ if ((q = strchr(p, '\r'))) *q = '\0'; @@ -1342,8 +1342,8 @@ int waitntrip(ntrip_t *ntrip, char *msg) } if (ntrip->state == 1) { /* read response */ - p = (char *)ntrip->buff + ntrip->nb; - if ((n = readtcpcli(ntrip->tcp, (unsigned char *)p, NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0) + p = reinterpret_cast(ntrip->buff) + ntrip->nb; + if ((n = readtcpcli(ntrip->tcp, reinterpret_cast(p), NTRIP_MAXRSP - ntrip->nb - 1, msg)) == 0) { tracet(5, "waitntrip: readtcp n=%d\n", n); return 0; @@ -1367,7 +1367,7 @@ ntrip_t *openntrip(const char *path, int type, char *msg) tracet(3, "openntrip: path=%s type=%d\n", path, type); - if (!(ntrip = (ntrip_t *)malloc(sizeof(ntrip_t)))) return nullptr; + if (!(ntrip = static_cast(malloc(sizeof(ntrip_t))))) return nullptr; ntrip->state = 0; ntrip->type = type; /* 0:server, 1:client */ @@ -1534,7 +1534,7 @@ gtime_t nextdltime(const int *topts, int stat) /* ftp thread ----------------------------------------------------------------*/ void *ftpthread(void *arg) { - auto *ftp = (ftp_t *)arg; + auto *ftp = static_cast(arg); FILE *fp; gtime_t time; char remote[1024], local[1024], tmpfile[1024], errfile[1024], *p; @@ -1578,7 +1578,7 @@ void *ftpthread(void *arg) { *p = '\0'; } - if ((fp = fopen(tmpfile, "rb"))) + if ((fp = fopen(tmpfile, "rbe"))) { fclose(fp); strcpy(ftp->local, tmpfile); @@ -1672,12 +1672,12 @@ ftp_t *openftp(const char *path, int type, char *msg) msg[0] = '\0'; - if (!(ftp = (ftp_t *)malloc(sizeof(ftp_t)))) return nullptr; + if (!(ftp = static_cast(malloc(sizeof(ftp_t))))) return nullptr; ftp->state = 0; ftp->proto = type; ftp->error = 0; - ftp->thread = 0; + ftp->thread = 0; // NOLINT ftp->local[0] = '\0'; /* decode ftp path */ @@ -1739,9 +1739,9 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) } /* return local file path if ftp completed */ p = buff; - q = (unsigned char *)ftp->local; - while (*q && (int)(p - buff) < n) *p++ = *q++; - p += sprintf((char *)p, "\r\n"); + q = reinterpret_cast(ftp->local); + while (*q && static_cast(p - buff) < n) *p++ = *q++; + p += sprintf(reinterpret_cast(p), "\r\n"); /* set next download time */ ftp->tnext = nextdltime(ftp->topts, 1); @@ -1749,7 +1749,7 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) strcpy(msg, ""); - return (int)(p - buff); + return static_cast(p - buff); } @@ -1888,28 +1888,28 @@ void strclose(stream_t *stream) switch (stream->type) { case STR_SERIAL: - closeserial((serial_t *)stream->port); + closeserial(static_cast(stream->port)); break; case STR_FILE: - closefile((file_t *)stream->port); + closefile(static_cast(stream->port)); break; case STR_TCPSVR: - closetcpsvr((tcpsvr_t *)stream->port); + closetcpsvr(static_cast(stream->port)); break; case STR_TCPCLI: - closetcpcli((tcpcli_t *)stream->port); + closetcpcli(static_cast(stream->port)); break; case STR_NTRIPSVR: - closentrip((ntrip_t *)stream->port); + closentrip(static_cast(stream->port)); break; case STR_NTRIPCLI: - closentrip((ntrip_t *)stream->port); + closentrip(static_cast(stream->port)); break; case STR_FTP: - closeftp((ftp_t *)stream->port); + closeftp(static_cast(stream->port)); break; case STR_HTTP: - closeftp((ftp_t *)stream->port); + closeftp(static_cast(stream->port)); break; } } @@ -1938,8 +1938,8 @@ void strsync(stream_t *stream1, stream_t *stream2) { file_t *file1, *file2; if (stream1->type != STR_FILE || stream2->type != STR_FILE) return; - file1 = (file_t *)stream1->port; - file2 = (file_t *)stream2->port; + file1 = static_cast(stream1->port); + file2 = static_cast(stream2->port); if (file1 && file2) syncfile(file1, file2); } @@ -1977,25 +1977,25 @@ int strread(stream_t *stream, unsigned char *buff, int n) switch (stream->type) { case STR_SERIAL: - nr = readserial((serial_t *)stream->port, buff, n, msg); + nr = readserial(static_cast(stream->port), buff, n, msg); break; case STR_FILE: - nr = readfile((file_t *)stream->port, buff, n, msg); + nr = readfile(static_cast(stream->port), buff, n, msg); break; case STR_TCPSVR: - nr = readtcpsvr((tcpsvr_t *)stream->port, buff, n, msg); + nr = readtcpsvr(static_cast(stream->port), buff, n, msg); break; case STR_TCPCLI: - nr = readtcpcli((tcpcli_t *)stream->port, buff, n, msg); + nr = readtcpcli(static_cast(stream->port), buff, n, msg); break; case STR_NTRIPCLI: - nr = readntrip((ntrip_t *)stream->port, buff, n, msg); + nr = readntrip(static_cast(stream->port), buff, n, msg); break; case STR_FTP: - nr = readftp((ftp_t *)stream->port, buff, n, msg); + nr = readftp(static_cast(stream->port), buff, n, msg); break; case STR_HTTP: - nr = readftp((ftp_t *)stream->port, buff, n, msg); + nr = readftp(static_cast(stream->port), buff, n, msg); break; default: strunlock(stream); @@ -2005,7 +2005,7 @@ int strread(stream_t *stream, unsigned char *buff, int n) tick = tickget(); if (nr > 0) stream->tact = tick; - if ((int)(tick - stream->tick) >= tirate) + if (static_cast(tick - stream->tick) >= tirate) { stream->inr = (stream->inb - stream->inbt) * 8000 / (tick - stream->tick); stream->tick = tick; @@ -2039,20 +2039,20 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) switch (stream->type) { case STR_SERIAL: - ns = writeserial((serial_t *)stream->port, buff, n, msg); + ns = writeserial(static_cast(stream->port), buff, n, msg); break; case STR_FILE: - ns = writefile((file_t *)stream->port, buff, n, msg); + ns = writefile(static_cast(stream->port), buff, n, msg); break; case STR_TCPSVR: - ns = writetcpsvr((tcpsvr_t *)stream->port, buff, n, msg); + ns = writetcpsvr(static_cast(stream->port), buff, n, msg); break; case STR_TCPCLI: - ns = writetcpcli((tcpcli_t *)stream->port, buff, n, msg); + ns = writetcpcli(static_cast(stream->port), buff, n, msg); break; case STR_NTRIPCLI: case STR_NTRIPSVR: - ns = writentrip((ntrip_t *)stream->port, buff, n, msg); + ns = writentrip(static_cast(stream->port), buff, n, msg); break; case STR_FTP: case STR_HTTP: @@ -2064,7 +2064,7 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) tick = tickget(); if (ns > 0) stream->tact = tick; - if ((int)(tick - stream->tick) > tirate) + if (static_cast(tick - stream->tick) > tirate) { stream->outr = (stream->outb - stream->outbt) * 8000 / (tick - stream->tick); stream->tick = tick; @@ -2104,32 +2104,32 @@ int strstat(stream_t *stream, char *msg) switch (stream->type) { case STR_SERIAL: - state = stateserial((serial_t *)stream->port); + state = stateserial(static_cast(stream->port)); break; case STR_FILE: - state = statefile((file_t *)stream->port); + state = statefile(static_cast(stream->port)); break; case STR_TCPSVR: - state = statetcpsvr((tcpsvr_t *)stream->port); + state = statetcpsvr(static_cast(stream->port)); break; case STR_TCPCLI: - state = statetcpcli((tcpcli_t *)stream->port); + state = statetcpcli(static_cast(stream->port)); break; case STR_NTRIPSVR: case STR_NTRIPCLI: - state = statentrip((ntrip_t *)stream->port); + state = statentrip(static_cast(stream->port)); break; case STR_FTP: - state = stateftp((ftp_t *)stream->port); + state = stateftp(static_cast(stream->port)); break; case STR_HTTP: - state = stateftp((ftp_t *)stream->port); + state = stateftp(static_cast(stream->port)); break; default: strunlock(stream); return 0; } - if (state == 2 && (int)(tickget() - stream->tact) <= TINTACT) state = 3; + if (state == 2 && static_cast(tickget() - stream->tact) <= TINTACT) state = 3; strunlock(stream); return state; } @@ -2198,11 +2198,11 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon) if (stream->type == STR_TCPCLI) { - tcpcli = (tcpcli_t *)stream->port; + tcpcli = static_cast(stream->port); } else if (stream->type == STR_NTRIPCLI || stream->type == STR_NTRIPSVR) { - tcpcli = ((ntrip_t *)stream->port)->tcp; + tcpcli = (static_cast(stream->port))->tcp; } else return; @@ -2245,7 +2245,7 @@ gtime_t strgettime(stream_t *stream) { file_t *file; if (stream->type == STR_FILE && (stream->mode & STR_MODE_R) && - (file = (file_t *)stream->port)) + (file = static_cast(stream->port))) { return timeadd(file->time, file->start); /* replay start time */ } @@ -2292,9 +2292,9 @@ int gen_hex(const char *msg, unsigned char *buff) } for (i = 0; i < narg; i++) { - if (sscanf(args[i], "%x", &byte)) *q++ = (unsigned char)byte; + if (sscanf(args[i], "%x", &byte)) *q++ = static_cast(byte); } - return (int)(q - buff); + return static_cast(q - buff); } @@ -2317,7 +2317,7 @@ void strsendcmd(stream_t *str, const char *cmd) { for (q = p;; q++) if (*q == '\r' || *q == '\n' || *q == '\0') break; - n = (int)(q - p); + n = static_cast(q - p); strncpy(msg, p, n); msg[n] = '\0'; @@ -2357,8 +2357,8 @@ void strsendcmd(stream_t *str, const char *cmd) } else { - strwrite(str, (unsigned char *)msg, n); - strwrite(str, (unsigned char *)cmdend, 2); + strwrite(str, reinterpret_cast(msg), n); + strwrite(str, reinterpret_cast(cmdend), 2); } if (*q == '\0') break; diff --git a/src/algorithms/libs/short_x2_to_cshort.cc b/src/algorithms/libs/short_x2_to_cshort.cc index 6463ab67a..90ce99a7e 100644 --- a/src/algorithms/libs/short_x2_to_cshort.cc +++ b/src/algorithms/libs/short_x2_to_cshort.cc @@ -41,8 +41,8 @@ short_x2_to_cshort_sptr make_short_x2_to_cshort() short_x2_to_cshort::short_x2_to_cshort() : sync_block("short_x2_to_cshort", - gr::io_signature::make(2, 2, sizeof(short)), - gr::io_signature::make(1, 1, sizeof(lv_16sc_t))) // lv_8sc_t is a Volk's typedef for std::complex + gr::io_signature::make(2, 2, sizeof(int16_t)), + gr::io_signature::make(1, 1, sizeof(lv_16sc_t))) { const int alignment_multiple = volk_get_alignment() / sizeof(lv_16sc_t); set_alignment(std::max(1, alignment_multiple)); @@ -53,12 +53,12 @@ int short_x2_to_cshort::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const auto *in0 = reinterpret_cast(input_items[0]); - const auto *in1 = reinterpret_cast(input_items[1]); + const auto *in0 = reinterpret_cast(input_items[0]); + const auto *in1 = reinterpret_cast(input_items[1]); auto *out = reinterpret_cast(output_items[0]); // This could be put into a volk kernel - short real_part; - short imag_part; + int16_t real_part; + int16_t imag_part; for (int number = 0; number < noutput_items; number++) { // lv_cmake(r, i) defined at volk/volk_complex.h diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index 685c28c49..c7228f2cd 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -542,7 +542,7 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) int32_t n_valid = 0; for (uint32_t n = 0; n < d_nchannels_out; n++) { - Gnss_Synchro interpolated_gnss_synchro; + Gnss_Synchro interpolated_gnss_synchro{}; if (!interp_trk_obs(interpolated_gnss_synchro, n, d_Rx_clock_buffer.front() + T_rx_TOW_offset_ms * T_rx_clock_step_samples)) { // Produce an empty observation diff --git a/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc b/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc index 8c128b47b..4c614ccba 100644 --- a/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc +++ b/src/algorithms/resampler/adapters/direct_resampler_conditioner.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include using google::LogMessage; @@ -94,7 +95,7 @@ DirectResamplerConditioner::DirectResamplerConditioner( else { LOG(WARNING) << item_type_ << " unrecognized item type for resampler"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) { diff --git a/src/algorithms/signal_generator/adapters/signal_generator.cc b/src/algorithms/signal_generator/adapters/signal_generator.cc index 72dafe542..fcde2b3a8 100644 --- a/src/algorithms/signal_generator/adapters/signal_generator.cc +++ b/src/algorithms/signal_generator/adapters/signal_generator.cc @@ -37,7 +37,7 @@ #include "Galileo_E5a.h" #include "GLONASS_L1_L2_CA.h" #include - +#include #include @@ -104,11 +104,11 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, { if (signal1[0].at(0) == '1') { - vector_length = round((float)fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); + vector_length = round(static_cast(fs_in) / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); } else { - vector_length = round((float)fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + vector_length = round(static_cast(fs_in) / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); } } @@ -128,7 +128,7 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type for resampler"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) diff --git a/src/algorithms/signal_source/adapters/labsat_signal_source.cc b/src/algorithms/signal_source/adapters/labsat_signal_source.cc index 6e31e2ac4..cf1278d9d 100644 --- a/src/algorithms/signal_source/adapters/labsat_signal_source.cc +++ b/src/algorithms/signal_source/adapters/labsat_signal_source.cc @@ -32,7 +32,7 @@ #include "configuration_interface.h" #include "labsat23_source.h" #include - +#include #include @@ -63,7 +63,7 @@ LabsatSignalSource::LabsatSignalSource(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type for LabSat source"; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (dump_) { diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc index 6e644119d..b0cbbf34b 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc @@ -36,6 +36,7 @@ #include "GPS_L1_CA.h" #include #include +#include #include #include @@ -63,7 +64,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, // rtl_tcp PARAMETERS std::string default_address = "127.0.0.1"; - short default_port = 1234; + int16_t default_port = 1234; AGC_enabled_ = configuration->property(role + ".AGC_enabled", true); freq_ = configuration->property(role + ".freq", GPS_L1_FREQ_HZ); gain_ = configuration->property(role + ".gain", 40.0); @@ -77,7 +78,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, if (item_type_ == "short") { - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } else if (item_type_ == "gr_complex") { @@ -118,7 +119,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, else { LOG(WARNING) << item_type_ << " unrecognized item type. Using short."; - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } if (samples_ != 0) diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index f06d5040b..9355537ce 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -90,7 +90,7 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac // well read them in as bytes. if (big_endian_items_) { - item_size_ = sizeof(short); + item_size_ = sizeof(int16_t); } else { diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index c633d97a5..2ae97cd1d 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -369,121 +369,118 @@ int labsat23_source::general_work(int noutput_items, std::cout << "Labsat file header error: section 2 is not available." << std::endl; return -1; } - else - { - std::cout << "Labsat file read error: file is empty." << std::endl; - return -1; - } + std::cout << "Labsat file read error: file is empty." << std::endl; + return -1; } - else + + + // ready to start reading samples + switch (d_bits_per_sample) { - // ready to start reading samples - switch (d_bits_per_sample) - { - case 2: + case 2: + { + switch (d_channel_selector) { - switch (d_channel_selector) - { - case 0: - // dual channel 2 bits per complex sample - break; - default: - // single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16) - int n_int16_to_read = noutput_items / 8; - if (n_int16_to_read > 0) - { - int16_t memblock[n_int16_to_read]; - binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); - n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 - if (n_int16_to_read > 0) - { - int output_pointer = 0; - for (int i = 0; i < n_int16_to_read; i++) - { - decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); - output_pointer += 8; - } - return output_pointer; - } - - // trigger the read of the next file in the sequence - std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; - - d_current_file_number++; - binary_input_file->close(); - binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); - if (binary_input_file->is_open()) - { - std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; - } - else - { - std::cout << "Last file reached, LabSat source stop" << std::endl; - return -1; - } - } - else - { - return 0; - } - }; + case 0: + // dual channel 2 bits per complex sample break; - } - case 4: - { - switch (d_channel_selector) + default: + // single channel 2 bits per complex sample (1 bit I + 1 bit Q, 8 samples per int16) + int n_int16_to_read = noutput_items / 8; + if (n_int16_to_read > 0) { - case 0: - // dual channel - break; - default: - // single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16) - int n_int16_to_read = noutput_items / 4; + int16_t memblock[n_int16_to_read]; + binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); + n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 if (n_int16_to_read > 0) { - int16_t memblock[n_int16_to_read]; - binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); - n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 - if (n_int16_to_read > 0) + int output_pointer = 0; + for (int i = 0; i < n_int16_to_read; i++) { - int output_pointer = 0; - for (int i = 0; i < n_int16_to_read; i++) - { - decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); - output_pointer += 4; - } - return output_pointer; + decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); + output_pointer += 8; } + return output_pointer; + } - // trigger the read of the next file in the sequence - std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; + // trigger the read of the next file in the sequence + std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; - d_current_file_number++; - binary_input_file->close(); - binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); - if (binary_input_file->is_open()) - { - std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; - } - else - { - std::cout << "Last file reached, LabSat source stop" << std::endl; - return -1; - } + d_current_file_number++; + binary_input_file->close(); + binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); + if (binary_input_file->is_open()) + { + std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; } else { - return 0; + std::cout << "Last file reached, LabSat source stop" << std::endl; + return -1; } } - break; - } - default: + else + { + return 0; + } + }; + break; + } + case 4: + { + switch (d_channel_selector) { - return -1; + case 0: + // dual channel + break; + default: + // single channel 4 bits per complex sample (2 bit I + 2 bit Q, 4 samples per int16) + int n_int16_to_read = noutput_items / 4; + if (n_int16_to_read > 0) + { + int16_t memblock[n_int16_to_read]; + binary_input_file->read(reinterpret_cast(memblock), n_int16_to_read * 2); + n_int16_to_read = binary_input_file->gcount() / 2; //from bytes to int16 + if (n_int16_to_read > 0) + { + int output_pointer = 0; + for (int i = 0; i < n_int16_to_read; i++) + { + decode_samples_one_channel(memblock[i], &out[output_pointer], d_bits_per_sample); + output_pointer += 4; + } + return output_pointer; + } + + // trigger the read of the next file in the sequence + std::cout << "End of current file, reading the next Labsat file in sequence: " << generate_filename() << std::endl; + + d_current_file_number++; + binary_input_file->close(); + binary_input_file->open(generate_filename().c_str(), std::ios::in | std::ios::binary); + if (binary_input_file->is_open()) + { + std::cout << "Labsat file source is reading samples from " << generate_filename() << std::endl; + } + else + { + std::cout << "Last file reached, LabSat source stop" << std::endl; + return -1; + } + } + else + { + return 0; + } } - } + break; + } + default: + { + return -1; + } } + std::cout << "Warning!!" << std::endl; return 0; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc index 0774d3762..1a70636cf 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.cc @@ -51,7 +51,7 @@ enum rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq) { return gnuradio::get_initial_sptr(new rtl_tcp_signal_source_c(address, @@ -61,7 +61,7 @@ rtl_tcp_make_signal_source_c(const std::string &address, rtl_tcp_signal_source_c::rtl_tcp_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq) : gr::sync_block("rtl_tcp_signal_source_c", gr::io_signature::make(0, 0, 0), diff --git a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h index 3c8c4529a..218d12166 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h +++ b/src/algorithms/signal_source/gnuradio_blocks/rtl_tcp_signal_source_c.h @@ -45,6 +45,7 @@ #include #include #include +#include #include class rtl_tcp_signal_source_c; @@ -54,7 +55,7 @@ typedef boost::shared_ptr rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq = false); /*! @@ -81,11 +82,11 @@ private: friend rtl_tcp_signal_source_c_sptr rtl_tcp_make_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq); rtl_tcp_signal_source_c(const std::string &address, - short port, + int16_t port, bool flip_iq); rtl_tcp_dongle_info info_; diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc index 4fc08e96e..1fd5c2032 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc @@ -62,9 +62,9 @@ bool systemIsBigEndian() bool systemBytesAreBigEndian() { - byte_and_samples b; + byte_and_samples b{}; b.byte = static_cast(0x01); - if (*(char *)&b.byte == 1) + if (*reinterpret_cast(&b.byte) == 1) return false; return true; @@ -158,7 +158,7 @@ int unpack_2bit_samples::work(int noutput_items, // 1) The samples in a byte are in big endian order // 2) The samples in a byte are in little endian order - byte_and_samples raw_byte; + byte_and_samples raw_byte{}; int n = 0; if (!reverse_interleaving_) diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc index ff9bffec4..692bc22d7 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_cpx_samples.cc @@ -35,6 +35,7 @@ #include "unpack_byte_2bit_cpx_samples.h" #include +#include struct byte_2bit_struct { @@ -49,8 +50,8 @@ unpack_byte_2bit_cpx_samples_sptr make_unpack_byte_2bit_cpx_samples() unpack_byte_2bit_cpx_samples::unpack_byte_2bit_cpx_samples() : sync_interpolator("unpack_byte_2bit_cpx_samples", - gr::io_signature::make(1, 1, sizeof(signed char)), - gr::io_signature::make(1, 1, sizeof(short)), + gr::io_signature::make(1, 1, sizeof(int8_t)), + gr::io_signature::make(1, 1, sizeof(int16_t)), 4) { } @@ -63,10 +64,10 @@ int unpack_byte_2bit_cpx_samples::work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - const auto *in = reinterpret_cast(input_items[0]); - auto *out = reinterpret_cast(output_items[0]); + const auto *in = reinterpret_cast(input_items[0]); + auto *out = reinterpret_cast(output_items[0]); - byte_2bit_struct sample; + byte_2bit_struct sample{}; int n = 0; for (int i = 0; i < noutput_items / 4; i++) { @@ -76,34 +77,34 @@ int unpack_byte_2bit_cpx_samples::work(int noutput_items, //* Least Significant Nibble - Sample n+1 //* Packing order in Nibble Q1 Q0 I1 I0 //normal - // signed char c = in[i]; + // int8_t c = in[i]; // //Q[n] // sample.two_bit_sample = (c>>6) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //I[n] // sample.two_bit_sample = (c>>4) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //Q[n+1] // sample.two_bit_sample = (c>>2) & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); // //I[n+1] // sample.two_bit_sample = c & 3; - // out[n++] = (2*(short)sample.two_bit_sample+1); + // out[n++] = (2*(int16_t)sample.two_bit_sample+1); //I/Q swap - signed char c = in[i]; + int8_t c = in[i]; //I[n] sample.two_bit_sample = (c >> 4) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //Q[n] sample.two_bit_sample = (c >> 6) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //I[n+1] sample.two_bit_sample = c & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); //Q[n+1] sample.two_bit_sample = (c >> 2) & 3; - out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); + out[n++] = (2 * static_cast(sample.two_bit_sample) + 1); } return noutput_items; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc index 3161534c9..28637016b 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_byte_2bit_samples.cc @@ -62,7 +62,7 @@ int unpack_byte_2bit_samples::work(int noutput_items, const auto *in = reinterpret_cast(input_items[0]); auto *out = reinterpret_cast(output_items[0]); - byte_2bit_struct sample; + byte_2bit_struct sample{}; int n = 0; for (int i = 0; i < noutput_items / 4; i++) { diff --git a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h index 9b1c12f43..983b94a29 100644 --- a/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h +++ b/src/algorithms/signal_source/libs/rtl_tcp_dongle_info.h @@ -42,7 +42,7 @@ class rtl_tcp_dongle_info { private: - char magic_[4]; + char magic_[4]{}; uint32_t tuner_type_; uint32_t tuner_gain_count_; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc index a6b732887..183cf5a88 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.cc @@ -463,7 +463,7 @@ int galileo_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_symbol = in[0][0]; // add new symbol to the symbol queue diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h index 6dc96f309..a78ee4d6b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_telemetry_decoder_cc.h @@ -125,7 +125,7 @@ private: // vars for Viterbi decoder int32_t *out0, *out1, *state0, *state1; - int32_t g_encoder[2]; + int32_t g_encoder[2]{}; const int32_t nn = 2; // Coding rate 1/n const int32_t KK = 7; // Constraint Length int32_t mm = KK - 1; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index d8b5fb1b6..d1ba8137a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -74,7 +74,7 @@ glonass_l1_ca_telemetry_decoder_cc::glonass_l1_ca_telemetry_decoder_cc( // preamble bits to sampled symbols d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); int32_t n = 0; - for (unsigned short d_preambles_bit : d_preambles_bits) + for (uint16_t d_preambles_bit : d_preambles_bits) { for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { @@ -268,7 +268,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_symbol = in[0][0]; d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index 4c8e6b57b..72fd730d2 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -82,7 +82,7 @@ private: double d_preamble_time_samples; //!< Preamble decoding - uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{}; int32_t *d_preambles_symbols; uint32_t d_samples_per_symbol; int32_t d_symbols_per_preamble; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc index 3b1651cba..7384486d8 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -74,7 +74,7 @@ glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( // preamble bits to sampled symbols d_preambles_symbols = static_cast(malloc(sizeof(int32_t) * d_symbols_per_preamble)); int32_t n = 0; - for (unsigned short d_preambles_bit : d_preambles_bits) + for (uint16_t d_preambles_bit : d_preambles_bits) { for (uint32_t j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) { @@ -268,7 +268,7 @@ int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_symbol = in[0][0]; d_symbol_history.push_back(current_symbol); // add new symbol to the symbol queue diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h index 8b834228a..e30c6326b 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h @@ -80,7 +80,7 @@ private: double d_preamble_time_samples; //!< Preamble decoding - uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; + uint16_t d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]{}; int32_t *d_preambles_symbols; uint32_t d_samples_per_symbol; int32_t d_symbols_per_preamble; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 9d4c04278..7dd78171c 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -67,7 +67,7 @@ gps_l1_ca_telemetry_decoder_cc::gps_l1_ca_telemetry_decoder_cc( // preamble bits to sampled symbols d_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); int32_t n = 0; - for (unsigned short preambles_bit : preambles_bits) + for (uint16_t preambles_bit : preambles_bits) { for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) { @@ -316,7 +316,7 @@ int gps_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__ auto **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer const auto **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_symbol = in[0][0]; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h index 745128047..5d7728821 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h @@ -82,7 +82,7 @@ private: // symbols boost::circular_buffer d_symbol_history; - float d_subframe_symbols[GPS_SUBFRAME_MS]; // symbols per subframe + float d_subframe_symbols[GPS_SUBFRAME_MS]{}; // symbols per subframe int d_current_subframe_symbol; // bits and frame diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc index da5e9e123..6bef581a4 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.cc @@ -143,7 +143,7 @@ int gps_l2c_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( consume_each(1); // one by one // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_synchro_data{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_synchro_data = in[0]; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h index 932fb6db7..97817c24f 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_cc.h @@ -91,7 +91,7 @@ private: std::string d_dump_filename; std::ofstream d_dump_file; - cnav_msg_decoder_t d_cnav_decoder; + cnav_msg_decoder_t d_cnav_decoder{}; int32_t d_state; int32_t d_crc_error_count; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 561be8878..76e64eaaf 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -145,7 +145,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer // UPDATE GNSS SYNCHRO DATA - Gnss_Synchro current_synchro_data; //structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_synchro_data{}; //structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_synchro_data = in[0]; consume_each(1); //one by one diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index e5e98cde6..4ca206e55 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -83,14 +83,14 @@ private: std::string d_dump_filename; std::ofstream d_dump_file; - cnav_msg_decoder_t d_cnav_decoder; + cnav_msg_decoder_t d_cnav_decoder{}; uint32_t d_TOW_at_current_symbol_ms; uint32_t d_TOW_at_Preamble_ms; bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; - double bits_NH[GPS_L5i_NH_CODE_LENGTH]; + double bits_NH[GPS_L5i_NH_CODE_LENGTH]{}; std::deque sym_hist; bool sync_NH; bool new_sym; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc index 8a6417cd0..acb071f51 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc @@ -425,7 +425,7 @@ int sbas_l1_telemetry_decoder_cc::general_work(int noutput_items __attribute__(( auto *out = reinterpret_cast(output_items[0]); // Get the output buffer pointer const auto *in = reinterpret_cast(input_items[0]); // Get the input buffer pointer - Gnss_Synchro current_symbol; // structure to save the synchronization information and send the output object to the next block + Gnss_Synchro current_symbol{}; // structure to save the synchronization information and send the output object to the next block // 1. Copy the current tracking output current_symbol = in[0]; // copy correlation samples into samples vector diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index af624f781..27da0a132 100755 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -133,7 +133,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl // preamble bits to sampled symbols d_gps_l1ca_preambles_symbols = static_cast(volk_gnsssdr_malloc(GPS_CA_PREAMBLE_LENGTH_SYMBOLS * sizeof(int32_t), volk_gnsssdr_get_alignment())); int32_t n = 0; - for (unsigned short preambles_bit : preambles_bits) + for (uint16_t preambles_bit : preambles_bits) { for (uint32_t j = 0; j < GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; j++) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index 71a31058d..74e6ef179 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -572,9 +572,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -913,9 +913,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index 6903c78e6..13d672ac5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -563,9 +563,9 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -902,9 +902,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index 311e4a49a..1ad32b44e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -569,9 +569,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -910,9 +910,9 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index 5ecb75f62..dcabc0a7c 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -562,9 +562,9 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -901,9 +901,9 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index aa794f286..8647fed8d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -551,9 +551,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -891,9 +891,9 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 63357b078..9b2f34cc7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -553,9 +553,9 @@ void gps_l1_ca_dll_pll_c_aid_tracking_sc::set_channel(uint32_t channel) d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what(); + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); } } } @@ -892,9 +892,9 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib uint32_t prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(uint32_t)); } - catch (const std::ifstream::failure *e) + catch (const std::ifstream::failure &e) { - LOG(WARNING) << "Exception writing trk dump file " << e->what(); + LOG(WARNING) << "Exception writing trk dump file " << e.what(); } } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc index 6700036d2..249ac5d32 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc @@ -517,7 +517,7 @@ int32_t Gps_L1_Ca_Kf_Tracking_cc::save_matfile() filename.erase(filename.length() - 4, 4); filename.append(".mat"); matfp = Mat_CreateVer(filename.c_str(), nullptr, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != nullptr) + if (reinterpret_cast(matfp) != nullptr) { size_t dims[2] = {1, static_cast(num_epoch)}; matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_VE, 0); diff --git a/src/algorithms/tracking/libs/dll_pll_conf.h b/src/algorithms/tracking/libs/dll_pll_conf.h index 0fbf07cc3..2304404b1 100644 --- a/src/algorithms/tracking/libs/dll_pll_conf.h +++ b/src/algorithms/tracking/libs/dll_pll_conf.h @@ -65,7 +65,7 @@ public: double carrier_lock_th; bool track_pilot; char system; - char signal[3]; + char signal[3]{}; Dll_Pll_Conf(); }; diff --git a/src/algorithms/tracking/libs/tcp_communication.cc b/src/algorithms/tracking/libs/tcp_communication.cc index 998006c1b..2ecd3c2a8 100644 --- a/src/algorithms/tracking/libs/tcp_communication.cc +++ b/src/algorithms/tracking/libs/tcp_communication.cc @@ -35,9 +35,7 @@ #include -tcp_communication::tcp_communication() : tcp_socket_(io_service_) -{ -} +tcp_communication::tcp_communication() : tcp_socket_(io_service_) {} // NOLINT tcp_communication::~tcp_communication() = default; diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.cc b/src/algorithms/tracking/libs/tracking_loop_filter.cc index 07ff8f730..6bb23c793 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.cc +++ b/src/algorithms/tracking/libs/tracking_loop_filter.cc @@ -52,6 +52,7 @@ Tracking_loop_filter::Tracking_loop_filter(float update_interval, update_coefficients(); } + Tracking_loop_filter::Tracking_loop_filter() : d_loop_order(2), d_current_index(0), @@ -64,10 +65,9 @@ Tracking_loop_filter::Tracking_loop_filter() update_coefficients(); } -Tracking_loop_filter::~Tracking_loop_filter() -{ - // Don't need to do anything here -} + +Tracking_loop_filter::~Tracking_loop_filter() = default; + float Tracking_loop_filter::apply(float current_input) { @@ -108,6 +108,7 @@ float Tracking_loop_filter::apply(float current_input) return result; } + void Tracking_loop_filter::update_coefficients(void) { // Analog gains: @@ -216,17 +217,20 @@ void Tracking_loop_filter::update_coefficients(void) }; } + void Tracking_loop_filter::set_noise_bandwidth(float noise_bandwidth) { d_noise_bandwidth = noise_bandwidth; update_coefficients(); } + float Tracking_loop_filter::get_noise_bandwidth(void) const { return d_noise_bandwidth; } + void Tracking_loop_filter::set_update_interval(float update_interval) { d_update_interval = update_interval; @@ -238,17 +242,20 @@ float Tracking_loop_filter::get_update_interval(void) const return d_update_interval; } + void Tracking_loop_filter::set_include_last_integrator(bool include_last_integrator) { d_include_last_integrator = include_last_integrator; update_coefficients(); } + bool Tracking_loop_filter::get_include_last_integrator(void) const { return d_include_last_integrator; } + void Tracking_loop_filter::set_order(int loop_order) { if (loop_order < 1 or loop_order > MAX_LOOP_ORDER) @@ -264,11 +271,13 @@ void Tracking_loop_filter::set_order(int loop_order) update_coefficients(); } + int Tracking_loop_filter::get_order(void) const { return d_loop_order; } + void Tracking_loop_filter::initialize(float initial_output) { d_inputs.assign(MAX_LOOP_HISTORY_LENGTH, 0.0); diff --git a/src/core/libs/INIReader.cc b/src/core/libs/INIReader.cc index 9589365bb..9ca9dd039 100644 --- a/src/core/libs/INIReader.cc +++ b/src/core/libs/INIReader.cc @@ -64,16 +64,16 @@ int INIReader::ParseError() } -std::string INIReader::Get(std::string section, std::string name, std::string default_value) +std::string INIReader::Get(const std::string& section, const std::string& name, std::string default_value) { - std::string key = MakeKey(std::move(section), std::move(name)); + std::string key = MakeKey(section, name); return _values.count(key) ? _values[key] : default_value; } -int64_t INIReader::GetInteger(std::string section, std::string name, int64_t default_value) +int64_t INIReader::GetInteger(const std::string& section, const std::string& name, int64_t default_value) { - std::string valstr = Get(std::move(section), std::move(name), ""); + std::string valstr = Get(section, name, ""); const char* value = valstr.c_str(); char* end; // This parses "1234" (decimal) and also "0x4D2" (hex) @@ -86,7 +86,7 @@ std::string INIReader::MakeKey(const std::string& section, const std::string& na { std::string key = section + "." + name; // Convert to lower case to make lookups case-insensitive - for (char & i : key) + for (char& i : key) i = tolower(i); return key; } diff --git a/src/core/libs/INIReader.h b/src/core/libs/INIReader.h index 53a8afb08..bfe168bd9 100644 --- a/src/core/libs/INIReader.h +++ b/src/core/libs/INIReader.h @@ -66,11 +66,11 @@ public: int ParseError(); //! Get a string value from INI file, returning default_value if not found. - std::string Get(std::string section, std::string name, + std::string Get(const std::string& section, const std::string& name, std::string default_value); //! Get an integer (long) value from INI file, returning default_value if not found. - int64_t GetInteger(std::string section, std::string name, int64_t default_value); + int64_t GetInteger(const std::string& section, const std::string& name, int64_t default_value); private: int _error; diff --git a/src/core/libs/gnss_sdr_supl_client.h b/src/core/libs/gnss_sdr_supl_client.h index d25df206a..2ea7f60c6 100644 --- a/src/core/libs/gnss_sdr_supl_client.h +++ b/src/core/libs/gnss_sdr_supl_client.h @@ -74,9 +74,9 @@ private: int lac; int ci; // assistance protocol structure - supl_ctx_t ctx; + supl_ctx_t ctx{}; // assistance data - supl_assist_t assist; + supl_assist_t assist{}; bool read_gal_almanac_from_gsa(const std::string& file_name); public: diff --git a/src/core/libs/string_converter.cc b/src/core/libs/string_converter.cc index a529ae5fd..ab84dab07 100644 --- a/src/core/libs/string_converter.cc +++ b/src/core/libs/string_converter.cc @@ -50,10 +50,8 @@ bool StringConverter::convert(const std::string& value, bool default_value) { return false; } - else - { - return default_value; - } + + return default_value; } diff --git a/src/core/libs/supl/asn-rrlp/converter-sample.c b/src/core/libs/supl/asn-rrlp/converter-sample.c index 13baad2e7..ee4abeb55 100644 --- a/src/core/libs/supl/asn-rrlp/converter-sample.c +++ b/src/core/libs/supl/asn-rrlp/converter-sample.c @@ -788,7 +788,7 @@ static int argument_is_stdin(char *av[], int idx) { static FILE *argument_to_file(char *av[], int idx) { return argument_is_stdin(av, idx) ? stdin - : fopen(av[idx], "r"); + : fopen(av[idx], "re"); } static char *argument_to_name(char *av[], int idx) { diff --git a/src/core/libs/supl/asn-rrlp/per_encoder.c b/src/core/libs/supl/asn-rrlp/per_encoder.c index f4bace060..8cf95347d 100644 --- a/src/core/libs/supl/asn-rrlp/per_encoder.c +++ b/src/core/libs/supl/asn-rrlp/per_encoder.c @@ -2,7 +2,7 @@ #include #include -static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); +static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); asn_enc_rval_t uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { diff --git a/src/core/libs/supl/asn-rrlp/per_opentype.c b/src/core/libs/supl/asn-rrlp/per_opentype.c index c81caed44..32152e132 100644 --- a/src/core/libs/supl/asn-rrlp/per_opentype.c +++ b/src/core/libs/supl/asn-rrlp/per_opentype.c @@ -17,7 +17,7 @@ typedef struct uper_ugot_key static int uper_ugot_refill(asn_per_data_t *pd); static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); -static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); +static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int asn_debug_indent; diff --git a/src/core/libs/supl/asn-supl/per_encoder.c b/src/core/libs/supl/asn-supl/per_encoder.c index f4bace060..8cf95347d 100644 --- a/src/core/libs/supl/asn-supl/per_encoder.c +++ b/src/core/libs/supl/asn-supl/per_encoder.c @@ -2,7 +2,7 @@ #include #include -static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t *, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); +static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, asn_per_constraints_t * /*constraints*/, void *sptr, asn_app_consume_bytes_f *cb, void *app_key); asn_enc_rval_t uper_encode(asn_TYPE_descriptor_t *td, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { diff --git a/src/core/libs/supl/asn-supl/per_opentype.c b/src/core/libs/supl/asn-supl/per_opentype.c index c81caed44..32152e132 100644 --- a/src/core/libs/supl/asn-supl/per_opentype.c +++ b/src/core/libs/supl/asn-supl/per_opentype.c @@ -17,7 +17,7 @@ typedef struct uper_ugot_key static int uper_ugot_refill(asn_per_data_t *pd); static int per_skip_bits(asn_per_data_t *pd, int skip_nbits); -static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); +static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t * /*ctx*/, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd); int asn_debug_indent; diff --git a/src/core/libs/supl/supl.c b/src/core/libs/supl/supl.c index 021b65327..651d541fd 100644 --- a/src/core/libs/supl/supl.c +++ b/src/core/libs/supl/supl.c @@ -274,7 +274,7 @@ static int server_connect(char *server) { } for (aip = ailist; aip; aip = aip->ai_next) { - if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) { + if ((fd = socket(aip->ai_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) { err = errno; } if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) { diff --git a/src/core/monitor/gnss_synchro_udp_sink.cc b/src/core/monitor/gnss_synchro_udp_sink.cc index 52b53b260..cdd4608a6 100644 --- a/src/core/monitor/gnss_synchro_udp_sink.cc +++ b/src/core/monitor/gnss_synchro_udp_sink.cc @@ -35,7 +35,7 @@ #include #include -Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector addresses, const unsigned short& port) : socket{io_service} +Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector addresses, const uint16_t& port) : socket{io_service} { for (auto address : addresses) { diff --git a/src/core/monitor/gnss_synchro_udp_sink.h b/src/core/monitor/gnss_synchro_udp_sink.h index cf3cfc91d..680aa455f 100644 --- a/src/core/monitor/gnss_synchro_udp_sink.h +++ b/src/core/monitor/gnss_synchro_udp_sink.h @@ -38,7 +38,7 @@ class Gnss_Synchro_Udp_Sink { public: - Gnss_Synchro_Udp_Sink(std::vector addresses, const unsigned short &port); + Gnss_Synchro_Udp_Sink(std::vector addresses, const uint16_t &port); bool write_gnss_synchro(std::vector stocks); private: diff --git a/src/core/system_parameters/rtcm.cc b/src/core/system_parameters/rtcm.cc index 5cd896eb3..d089f3779 100644 --- a/src/core/system_parameters/rtcm.cc +++ b/src/core/system_parameters/rtcm.cc @@ -301,7 +301,7 @@ int32_t Rtcm::bin_to_int(const std::string& s) const int32_t reading; // Handle negative numbers - if (s.substr(0, 1).compare("0")) + if (s.substr(0, 1) != "0") { // Computing two's complement boost::dynamic_bitset<> original_bitset(s); @@ -327,7 +327,7 @@ int32_t Rtcm::bin_to_sint(const std::string& s) const int32_t sign; // Check for sign bit as defined RTCM doc - if (s.substr(0, 1) == "0") + if (s.substr(0, 1) != "0") { sign = 1; // Get the magnitude of the value @@ -363,7 +363,7 @@ double Rtcm::bin_to_double(const std::string& s) const int64_t reading_int; // Handle negative numbers - if (s.substr(0, 1).compare("0")) + if (s.substr(0, 1) != "0") { // Computing two's complement boost::dynamic_bitset<> original_bitset(s); diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index e5efd2150..97b672e94 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -121,7 +121,7 @@ int PositionSystemTest::generate_signal() pid_t wait_result; int child_status; - char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], NULL}; + char* const parmList[] = {&generator_binary[0], &generator_binary[0], &p1[0], &p2[0], &p3[0], &p4[0], &p5[0], nullptr}; int pid; if ((pid = fork()) == -1) @@ -342,12 +342,12 @@ int PositionSystemTest::run_receiver() std::string argum2 = std::string("/bin/ls *kml | tail -1"); char buffer[1035]; fp = popen(&argum2[0], "r"); - if (fp == NULL) + if (fp == nullptr) { std::cout << "Failed to run command: " << argum2 << std::endl; return -1; } - while (fgets(buffer, sizeof(buffer), fp) != NULL) + while (fgets(buffer, sizeof(buffer), fp) != nullptr) { std::string aux = std::string(buffer); EXPECT_EQ(aux.empty(), false); @@ -910,7 +910,7 @@ void PositionSystemTest::print_results(const arma::mat& R_eb_enu) } } -TEST_F(PositionSystemTest, Position_system_test) +TEST_F(PositionSystemTest /*unused*/, Position_system_test /*unused*/) { if (FLAGS_config_file_ptest.empty()) { diff --git a/src/tests/system-tests/ttff.cc b/src/tests/system-tests/ttff.cc index 6bea0a570..2820de29a 100644 --- a/src/tests/system-tests/ttff.cc +++ b/src/tests/system-tests/ttff.cc @@ -417,7 +417,7 @@ void TtffTest::print_TTFF_report(const std::vector &ttff_v, std::shared_ } -TEST_F(TtffTest, ColdStart) +TEST_F(TtffTest /*unused*/, ColdStart /*unused*/) { unsigned int num_measurements = 0; @@ -500,7 +500,7 @@ TEST_F(TtffTest, ColdStart) } -TEST_F(TtffTest, HotStart) +TEST_F(TtffTest /*unused*/, HotStart /*unused*/) { unsigned int num_measurements = 0; TTFF_v.clear(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index 624e02bd5..1f3f2cd04 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -62,7 +62,7 @@ // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsAcquisitionTest_msg_rx; -typedef boost::shared_ptr GpsL1CaPcpsAcquisitionTest_msg_rx_sptr; +using GpsL1CaPcpsAcquisitionTest_msg_rx_sptr = boost::shared_ptr; GpsL1CaPcpsAcquisitionTest_msg_rx_sptr GpsL1CaPcpsAcquisitionTest_msg_rx_make(); @@ -134,7 +134,7 @@ protected: gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; - Gnss_Synchro gnss_synchro; + Gnss_Synchro gnss_synchro{}; size_t item_size; unsigned int doppler_max; unsigned int doppler_step; diff --git a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc index bfd403b46..9c6540e9b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/adapter/adapter_test.cc @@ -61,7 +61,7 @@ public: std::string file_name_input; std::string file_name_output; std::vector input_data_bytes; - std::vector input_data_shorts; + std::vector input_data_shorts; }; @@ -70,12 +70,12 @@ DataTypeAdapter::DataTypeAdapter() file_name_input = "adapter_test_input.dat"; file_name_output = "adapter_test_output.dat"; int8_t input_bytes[] = {2, 23, -1, 127, -127, 0}; - short input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255}; + int16_t input_shorts[] = {2, 23, -1, 127, -127, 0, 255, 255}; const std::vector input_data_bytes_(input_bytes, input_bytes + sizeof(input_bytes) / sizeof(int8_t)); input_data_bytes = input_data_bytes_; - const std::vector input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(short)); + const std::vector input_data_shorts_(input_shorts, input_shorts + sizeof(input_shorts) / sizeof(int16_t)); input_data_shorts = input_data_shorts_; } @@ -92,14 +92,14 @@ int DataTypeAdapter::run_ishort_to_cshort_block() EXPECT_EQ(expected_implementation, ishort_to_cshort->implementation()); std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary); - for (short aux : input_data_shorts) + for (int16_t aux : input_data_shorts) { - ofs.write(reinterpret_cast(&aux), sizeof(short)); + ofs.write(reinterpret_cast(&aux), sizeof(int16_t)); } ofs.close(); auto top_block = gr::make_top_block("Ishort_To_Cshort test"); - auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str()); + auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str()); auto sink = gr::blocks::file_sink::make(sizeof(lv_16sc_t), file_name_output.c_str(), false); EXPECT_NO_THROW({ @@ -120,14 +120,14 @@ int DataTypeAdapter::run_ishort_to_complex_block() EXPECT_EQ(expected_implementation, ishort_to_complex->implementation()); std::ofstream ofs(file_name_input.c_str(), std::ofstream::binary); - for (short aux : input_data_shorts) + for (int16_t aux : input_data_shorts) { - ofs.write(reinterpret_cast(&aux), sizeof(short)); + ofs.write(reinterpret_cast(&aux), sizeof(int16_t)); } ofs.close(); auto top_block = gr::make_top_block("Ishort_To_Complex test"); - auto file_source = gr::blocks::file_source::make(sizeof(short), file_name_input.c_str()); + auto file_source = gr::blocks::file_source::make(sizeof(int16_t), file_name_input.c_str()); auto sink = gr::blocks::file_sink::make(sizeof(gr_complex), file_name_output.c_str(), false); EXPECT_NO_THROW({ @@ -212,7 +212,7 @@ int DataTypeAdapter::run_ibyte_to_cbyte_block() auto top_block = gr::make_top_block("Ibyte_To_Cbyte test"); auto file_source = gr::blocks::file_source::make(sizeof(int8_t), file_name_input.c_str()); - auto sink = gr::blocks::file_sink::make(sizeof(short), file_name_output.c_str(), false); + auto sink = gr::blocks::file_sink::make(sizeof(int16_t), file_name_output.c_str(), false); EXPECT_NO_THROW({ top_block->connect(file_source, 0, ibyte_to_cbyte->get_left_block(), 0); @@ -364,9 +364,9 @@ TEST_F(DataTypeAdapter, IshortToComplexValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(gr_complex))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); i++; } } @@ -390,9 +390,9 @@ TEST_F(DataTypeAdapter, IshortToCshortValidationOfResults) { while (ifs.read(reinterpret_cast(&iSample), sizeof(lv_16sc_t))) { - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.real())); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); i++; } } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc index 372bdef1d..5c521f279 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e1_dll_pll_veml_tracking_test.cc @@ -73,7 +73,7 @@ protected: gr::top_block_sptr top_block; std::shared_ptr factory; std::shared_ptr config; - Gnss_Synchro gnss_synchro; + Gnss_Synchro gnss_synchro{}; size_t item_size; bool stop; int message; diff --git a/src/utils/front-end-cal/front_end_cal.cc b/src/utils/front-end-cal/front_end_cal.cc index a9394f370..4f66a6fd7 100644 --- a/src/utils/front-end-cal/front_end_cal.cc +++ b/src/utils/front-end-cal/front_end_cal.cc @@ -257,16 +257,14 @@ bool FrontEndCal::get_ephemeris() } return true; } - else + + std::cout << "Trying to read ephemeris from SUPL server..." << std::endl; + LOG(INFO) << "Trying to read ephemeris from SUPL server..."; + if (Get_SUPL_Assist() == 0) { - std::cout << "Trying to read ephemeris from SUPL server..." << std::endl; - LOG(INFO) << "Trying to read ephemeris from SUPL server..."; - if (Get_SUPL_Assist() == 0) - { - return true; - } - return false; + return true; } + return false; } diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index a826331c6..379465faa 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -66,7 +66,7 @@ #include #include #include -#include +#include #include #include #include // for ctime @@ -97,7 +97,7 @@ std::vector gnss_sync_vector; // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class FrontEndCal_msg_rx; -typedef boost::shared_ptr FrontEndCal_msg_rx_sptr; +using FrontEndCal_msg_rx_sptr = boost::shared_ptr; FrontEndCal_msg_rx_sptr FrontEndCal_msg_rx_make(); @@ -402,7 +402,7 @@ int main(int argc, char** argv) // record startup time std::chrono::time_point start, end; - std::chrono::duration elapsed_seconds; + std::chrono::duration elapsed_seconds{}; start = std::chrono::system_clock::now(); bool start_msg = true; @@ -434,7 +434,7 @@ int main(int argc, char** argv) { std::cout << " " << PRN << " "; double doppler_measurement_hz = 0; - for (auto & it : gnss_sync_vector) + for (auto& it : gnss_sync_vector) { doppler_measurement_hz += it.Acq_doppler_hz; } @@ -541,7 +541,7 @@ int main(int argc, char** argv) std::cout << "SV ID Measured [Hz] Predicted [Hz]" << std::endl; - for (auto & it : doppler_measurements_map) + for (auto& it : doppler_measurements_map) { try { @@ -577,7 +577,7 @@ int main(int argc, char** argv) double mean_osc_err_ppm = 0; int n_elements = f_if_estimation_Hz_map.size(); - for (auto & it : f_if_estimation_Hz_map) + for (auto& it : f_if_estimation_Hz_map) { mean_f_if_Hz += it.second; mean_fs_Hz += f_fs_estimation_Hz_map.find(it.first)->second; @@ -598,7 +598,7 @@ int main(int argc, char** argv) << "Corrected Doppler vs. Predicted" << std::endl; std::cout << "SV ID Corrected [Hz] Predicted [Hz]" << std::endl; - for (auto & it : doppler_measurements_map) + for (auto& it : doppler_measurements_map) { try { From 8925ca7066d54bf0969f764636814fabc969d26e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 8 Dec 2018 19:08:53 +0100 Subject: [PATCH 4/6] Fix building in Mac OS --- src/algorithms/libs/rtklib/rtklib_stream.cc | 10 +++-- src/core/libs/supl/supl.c | 45 ++++++++++----------- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 3225a791a..85fd0ad7e 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -90,7 +90,9 @@ serial_t *openserial(const char *path, int mode, char *msg) const speed_t bs[] = { B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200, B230400}; - struct termios ios{}; + struct termios ios + { + }; int rw = 0; tracet(3, "openserial: path=%s mode=%d\n", path, mode); @@ -714,7 +716,7 @@ int gentcp(tcp_t *tcp, int type, char *msg) tracet(3, "gentcp: type=%d\n", type); /* generate socket */ - if ((tcp->sock = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) == -1) + if ((tcp->sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { sprintf(msg, "socket error (%d)", errsock()); tracet(1, "gentcp: socket error err=%d\n", errsock()); @@ -866,7 +868,9 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) /* accept client connection --------------------------------------------------*/ int accsock(tcpsvr_t *tcpsvr, char *msg) { - struct sockaddr_in addr{}; + struct sockaddr_in addr + { + }; socket_t sock; socklen_t len = sizeof(addr); int i, err; diff --git a/src/core/libs/supl/supl.c b/src/core/libs/supl/supl.c index 651d541fd..3722d1af0 100644 --- a/src/core/libs/supl/supl.c +++ b/src/core/libs/supl/supl.c @@ -211,10 +211,10 @@ int EXPORT supl_decode_rrlp(supl_ulp_t *ulp_pdu, PDU_t **ret_rrlp) { ret_rrlp = 0; return E_SUPL_DECODE_RRLP; } - + return E_SUPL_INTERNAL; } - + int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { int err; SSL_METHOD *meth; @@ -225,7 +225,7 @@ int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { SSL_load_error_strings(); ctx->ssl_ctx = SSL_CTX_new(meth); if (!ctx->ssl_ctx) return E_SUPL_CONNECT; - + ctx->ssl = SSL_new(ctx->ssl_ctx); if (!ctx->ssl) return E_SUPL_CONNECT; @@ -242,13 +242,13 @@ int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { { X509 *s_cert = SSL_get_peer_certificate(ctx->ssl); FILE *fp = fopen("/tmp/s_cert.pem", "w"); - if (fp) + if (fp) PEM_write_X509(fp, s_cert); fclose(fp); X509_free(s_cert); } #endif - + return 0; } @@ -274,7 +274,7 @@ static int server_connect(char *server) { } for (aip = ailist; aip; aip = aip->ai_next) { - if ((fd = socket(aip->ai_family, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) { + if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) { err = errno; } if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) { @@ -315,15 +315,15 @@ static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu) { ulp->message.choice.msSUPLSTART.sETCapabilities.posProtocol.rrlp = 1; if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; @@ -447,15 +447,15 @@ static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu) { ulp->message.choice.msSUPLPOSINIT.requestedAssistData = req_adata; if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; @@ -512,7 +512,7 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) rrlp_ack->referenceNumber = rrlp->referenceNumber; rrlp_ack->component.present = RRLP_Component_PR_assistanceDataAck; - + ret = uper_encode_to_buffer(&asn_DEF_PDU, rrlp_ack, buffer, sizeof(buffer)); asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp_ack, 0); if (ret.encoded == -1) { @@ -524,12 +524,12 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) ulp = calloc(1, sizeof(ULP_PDU_t)); session_id = calloc(1, sizeof(SetSessionID_t)); - + ulp->length = 0; ulp->version.maj = 1; ulp->version.min = 0; ulp->version.servind = 0; - + session_id->sessionId = 1; // session_id->setId.present = SETId_PR_msisdn; // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); @@ -594,7 +594,7 @@ int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval loc->buf[3]; if (loc->buf[1] & 0x80) l *= -1; lat = 90.0 / (1 << 23) * l; - + l = (loc->buf[4] << 16) | (loc->buf[5] << 8) | loc->buf[6]; @@ -612,7 +612,7 @@ int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval assist->pos.uncertainty = l; } } - + if (hdr->acquisAssist) { int n; @@ -825,7 +825,7 @@ int EXPORT supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist) supl_response_harvest(ctx, &ulp); supl_ulp_free(&ulp); - + /* ** send SUPL_POS_INIT */ @@ -949,4 +949,3 @@ void EXPORT supl_set_debug(FILE *log, int flags) { if (flags & SUPL_DEBUG_DEBUG) debug.debug = 1; #endif } - From acacbbe1664ef4268a113c4acf636fc39e873b98 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 8 Dec 2018 20:09:25 +0100 Subject: [PATCH 5/6] Fix compilation --- src/tests/system-tests/position_test.cc | 12 ++++++------ src/tests/system-tests/ttff.cc | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index 97b672e94..af63e8b38 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -70,8 +70,8 @@ public: int configure_receiver(); int run_receiver(); void check_results(); - bool save_mat_xy(std::vector& x, std::vector& y, std::string filename); - bool save_mat_x(std::vector& x, std::string filename); + bool save_mat_xy(std::vector* x, std::vector* y, std::string filename); + bool save_mat_x(std::vector* x, std::string filename); std::string config_filename_no_extension; private: @@ -359,7 +359,7 @@ int PositionSystemTest::run_receiver() } -bool PositionSystemTest::save_mat_xy(std::vector& x, std::vector& y, std::string filename) +bool PositionSystemTest::save_mat_xy(std::vector* x, std::vector* y, std::string filename) { try { @@ -371,7 +371,7 @@ bool PositionSystemTest::save_mat_xy(std::vector& x, std::vector matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT5); if (reinterpret_cast(matfp) != NULL) { - size_t dims[2] = {1, x.size()}; + size_t dims[2] = {1, x->size()}; matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); @@ -394,7 +394,7 @@ bool PositionSystemTest::save_mat_xy(std::vector& x, std::vector } } -bool PositionSystemTest::save_mat_x(std::vector& x, std::string filename) +bool PositionSystemTest::save_mat_x(std::vector* x, std::string filename) { try { @@ -406,7 +406,7 @@ bool PositionSystemTest::save_mat_x(std::vector& x, std::string filename matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT5); if (reinterpret_cast(matfp) != NULL) { - size_t dims[2] = {1, x.size()}; + size_t dims[2] = {1, x->size()}; matvar = Mat_VarCreate("x", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, &x[0], 0); Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE Mat_VarFree(matvar); diff --git a/src/tests/system-tests/ttff.cc b/src/tests/system-tests/ttff.cc index 2820de29a..8d0cc4328 100644 --- a/src/tests/system-tests/ttff.cc +++ b/src/tests/system-tests/ttff.cc @@ -398,7 +398,7 @@ void TtffTest::print_TTFF_report(const std::vector &ttff_v, std::shared_ stm << "Navigation mode: " << "3D" << std::endl; - if (source.compare("UHD_Signal_Source")) + if (source != "UHD_Signal_Source") { stm << "Source: File" << std::endl; } From add5ba8112654e8ffbd6ea3d1977a9776e84069b Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 8 Dec 2018 23:16:10 +0100 Subject: [PATCH 6/6] Add .clang-tidy file and generate a compile_commands.json file containing the exact compiler calls for all translation units of the project in machine-readable form if clang-tidy is detected --- .clang-tidy | 3 +++ CMakeLists.txt | 28 +++++++++++++++++++++++++++- docs/changelog | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..5eb3cab9e --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,3 @@ +--- +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,llvm-header-guard,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-deprecated-headers,modernize-loop-convert,modernize-pass-by-value,modernize-raw-string-literal,modernize-use-auto,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,modernize-use-using,performance-faster-string-find,performance-move-const-arg,readability-named-parameter,readability-string-compare' +HeaderFilterRegex: '.*' diff --git a/CMakeLists.txt b/CMakeLists.txt index fceeb244b..41c2685a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1131,7 +1131,13 @@ if(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_VERS endif() message(FATAL_ERROR "libtool is required to build matio from source") endif() - if(EXISTS "/usr/bin/aclocal" OR EXISTS "/usr/bin/aclocal-1.16" OR EXISTS "/usr/bin/aclocal-1.15" OR EXISTS "/usr/bin/aclocal-1.14" OR EXISTS "/usr/bin/aclocal-1.13" OR EXISTS "/usr/bin/aclocal-1.11" OR EXISTS "/usr/bin/aclocal-1.10") + if(EXISTS "/usr/bin/aclocal" OR + EXISTS "/usr/bin/aclocal-1.16" OR + EXISTS "/usr/bin/aclocal-1.15" OR + EXISTS "/usr/bin/aclocal-1.14" OR + EXISTS "/usr/bin/aclocal-1.13" OR + EXISTS "/usr/bin/aclocal-1.11" OR + EXISTS "/usr/bin/aclocal-1.10") message(STATUS "Automake found.") else() message(" aclocal has not been found.") @@ -1612,6 +1618,26 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU endif() +######################################################################## +# clang-tidy https://clang.llvm.org/extra/clang-tidy/index.html +######################################################################## +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + if(NOT (CMAKE_VERSION VERSION_LESS "3.6")) + find_program( + CLANG_TIDY_EXE + NAMES "clang-tidy" + DOC "Path to clang-tidy executable" + ) + if(NOT CLANG_TIDY_EXE) + message(STATUS "clang-tidy not found.") + else() + message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}") + set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" "-checks=*") + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + endif() + endif() +endif() + ######################################################################## # Create uninstall target diff --git a/docs/changelog b/docs/changelog index 2382a4779..aa77a3554 100644 --- a/docs/changelog +++ b/docs/changelog @@ -71,6 +71,7 @@ Next release will have several improvements in different dimensions, addition of - Improvement in C++ usage: The override special identifier is now used when overriding a virtual function. This helps the compiler to check for type changes in the base class, making the detection of errors easier. - Improvement in C++ usage: A number of unused includes have been removed. Order of includes set to: local (in-source) headers, then library headers, then system headers. This helps to detect missing includes. - Improvement in C++ usage: Enhanced const correctness. Misuses of those variables are detected by the compiler. +- Improved code with clang-tidy and generation of a compile_commands.json file containing the exact compiler calls for all translation units of the project in machine-readable form if clang-tidy is detected. - Applied some style rules to CMake scripts. - Minimal versions of dependencies identified and detected.