From b8f5da341b402caba5af227eed248991c8e15e01 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 16 Mar 2020 11:51:50 +0100 Subject: [PATCH] Fix redundant comparison Use std::llabs instead of abs --- .../gps_l2c_telemetry_decoder_gs.cc | 3 +-- .../gps_l5_telemetry_decoder_gs.cc | 16 ++++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc index f5e81a45c..e2c1cf41d 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l2c_telemetry_decoder_gs.cc @@ -176,7 +176,7 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( // check if new CNAV frame is available if (flag_new_cnav_frame == true) { - if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part1.invert == true) + if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part2.invert == true) { flag_PLL_180_deg_phase_locked = true; } @@ -235,7 +235,6 @@ int gps_l2c_telemetry_decoder_gs::general_work(int noutput_items __attribute__(( } } - if (flag_PLL_180_deg_phase_locked == true) { // correct the accumulated phase for the Costas loop phase shift, if required diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc index bb0b74f1c..cbf0483dd 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_gs.cc @@ -28,11 +28,11 @@ #include #include // for make_any #include // for mp -#include -#include // for abs -#include // for exception -#include -#include // for shared_ptr, make_shared +#include // for std::bitset +#include // for std::llabs +#include // for std::exception +#include // for std::cout +#include // for shared_ptr, make_shared gps_l5_telemetry_decoder_gs_sptr @@ -168,7 +168,7 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u // check if new CNAV frame is available if (cnav_msg_decoder_add_symbol(&d_cnav_decoder, symbol_clip, &msg, &delay) == true) { - if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part1.invert == true) + if (d_cnav_decoder.part1.invert == true or d_cnav_decoder.part2.invert == true) { flag_PLL_180_deg_phase_locked = true; } @@ -218,10 +218,10 @@ int gps_l5_telemetry_decoder_gs::general_work(int noutput_items __attribute__((u // check TOW update consistency uint32_t last_d_TOW_at_current_symbol_ms = d_TOW_at_current_symbol_ms; d_TOW_at_current_symbol_ms = msg.tow * 6000 + (delay + 12) * GPS_L5I_SYMBOL_PERIOD_MS; - if (last_d_TOW_at_current_symbol_ms != 0 and abs(static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms)) > GPS_L5I_SYMBOL_PERIOD_MS) + if (last_d_TOW_at_current_symbol_ms != 0 and std::llabs(static_cast(d_TOW_at_current_symbol_ms) - static_cast(last_d_TOW_at_current_symbol_ms)) > static_cast(GPS_L5I_SYMBOL_PERIOD_MS)) { DLOG(INFO) << "Warning: GPS L5 TOW update in ch " << d_channel - << " does not match the TLM TOW counter " << static_cast(d_TOW_at_current_symbol_ms) - int64_t(last_d_TOW_at_current_symbol_ms) << " ms " + << " does not match the TLM TOW counter " << static_cast(d_TOW_at_current_symbol_ms) - static_cast(last_d_TOW_at_current_symbol_ms) << " ms " << " with delay: " << delay << " msg tow: " << msg.tow * 6000 << " ms \n"; d_TOW_at_current_symbol_ms = 0;