From 3cd1e70706a9e1797d484ddbbc92c498b4322c4e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 19 Mar 2019 07:53:21 +0100 Subject: [PATCH] Fix defects detected by Coverity Scan --- .../beidou_b3i_telemetry_decoder_gs.cc | 3 +- .../gnuradio_blocks/dll_pll_veml_tracking.cc | 82 ++++++++++--------- .../beidou_dnav_navigation_message.cc | 6 +- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc index e1920e2d1..6e65de72a 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/beidou_b3i_telemetry_decoder_gs.cc @@ -136,7 +136,8 @@ beidou_b3i_telemetry_decoder_gs::beidou_b3i_telemetry_decoder_gs( d_stat = 0; d_preamble_index = 0; d_flag_frame_sync = false; - d_TOW_at_current_symbol_ms = 0; + d_TOW_at_current_symbol_ms = 0U; + d_TOW_at_Preamble_ms = 0U; Flag_valid_word = false; d_CRC_error_counter = 0; d_flag_preamble = false; 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 c424f6c59..b98a5e567 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -74,45 +74,6 @@ dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_) } -void dll_pll_veml_tracking::forecast(int noutput_items, - gr_vector_int &ninput_items_required) -{ - if (noutput_items != 0) - { - ninput_items_required[0] = static_cast(trk_parameters.vector_length) * 2; - } -} - -void dll_pll_veml_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) -{ - try - { - if (pmt::any_ref(msg).type() == typeid(int)) - { - int tlm_event; - tlm_event = boost::any_cast(pmt::any_ref(msg)); - - switch (tlm_event) - { - case 1: //tlm fault in current channel - { - DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel; - gr::thread::scoped_lock lock(d_setlock); - d_carrier_lock_fail_counter = 10000; //force loss-of-lock condition - break; - } - default: - { - break; - } - } - } - } - catch (boost::bad_any_cast &e) - { - LOG(WARNING) << "msg_handler_telemetry_to_trk Bad any cast!"; - } -} dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::block("dll_pll_veml_tracking", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { @@ -468,6 +429,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_acq_sample_stamp = 0ULL; d_current_prn_length_samples = static_cast(trk_parameters.vector_length); + d_current_correlation_time_s = 0.0; // CN0 estimation and lock detector buffers d_cn0_estimation_counter = 0; @@ -542,6 +504,48 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl } +void dll_pll_veml_tracking::forecast(int noutput_items, + gr_vector_int &ninput_items_required) +{ + if (noutput_items != 0) + { + ninput_items_required[0] = static_cast(trk_parameters.vector_length) * 2; + } +} + + +void dll_pll_veml_tracking::msg_handler_telemetry_to_trk(const pmt::pmt_t &msg) +{ + try + { + if (pmt::any_ref(msg).type() == typeid(int)) + { + int tlm_event; + tlm_event = boost::any_cast(pmt::any_ref(msg)); + + switch (tlm_event) + { + case 1: //tlm fault in current channel + { + DLOG(INFO) << "Telemetry fault received in ch " << this->d_channel; + gr::thread::scoped_lock lock(d_setlock); + d_carrier_lock_fail_counter = 10000; //force loss-of-lock condition + break; + } + default: + { + break; + } + } + } + } + catch (boost::bad_any_cast &e) + { + LOG(WARNING) << "msg_handler_telemetry_to_trk Bad any cast!"; + } +} + + void dll_pll_veml_tracking::start_tracking() { gr::thread::scoped_lock l(d_setlock); diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.cc b/src/core/system_parameters/beidou_dnav_navigation_message.cc index 4fa6d017d..31b617db6 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.cc +++ b/src/core/system_parameters/beidou_dnav_navigation_message.cc @@ -830,7 +830,7 @@ int32_t Beidou_Dnav_Navigation_Message::d2_subframe_decoder(std::string const& s d_eccentricity_msb = static_cast(read_navigation_unsigned(subframe_bits, D2_E_MSB)); d_eccentricity_msb_bits = (read_navigation_unsigned(subframe_bits, D2_E_MSB)); // Adjust for lsb in next page (shift number of lsb to the left) - d_eccentricity_msb = static_cast((static_cast(d_eccentricity_msb) << 22)); + d_eccentricity_msb = static_cast((static_cast(d_eccentricity_msb) << 22)); d_eccentricity_msb_bits = d_eccentricity_msb_bits << 22; // Set system flags for message reception @@ -996,7 +996,7 @@ Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() eph.i_SV_accuracy = i_SV_accuracy; eph.i_SV_health = i_SV_health; eph.i_BEIDOU_week = i_BEIDOU_week; - eph.i_sig_type = i_signal_type; + eph.i_sig_type = i_signal_type; eph.i_nav_type = 2; eph.d_TOW = d_SOW; @@ -1043,7 +1043,7 @@ Beidou_Dnav_Ephemeris Beidou_Dnav_Navigation_Message::get_ephemeris() eph.i_SV_accuracy = i_SV_accuracy; eph.i_SV_health = i_SV_health; eph.i_BEIDOU_week = i_BEIDOU_week; - eph.i_sig_type = i_signal_type; + eph.i_sig_type = i_signal_type; eph.i_nav_type = 1; // MEO/IGSO eph.d_TOW = d_SOW;