From 5842f72f5270f15d7774558fb7d29bd7c30e0bf0 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 14 Nov 2023 15:12:16 +0100 Subject: [PATCH 1/4] This cast is required in some environments --- src/algorithms/signal_source/adapters/zmq_signal_source.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/signal_source/adapters/zmq_signal_source.cc b/src/algorithms/signal_source/adapters/zmq_signal_source.cc index caa4a9b9c..bc8616ccd 100644 --- a/src/algorithms/signal_source/adapters/zmq_signal_source.cc +++ b/src/algorithms/signal_source/adapters/zmq_signal_source.cc @@ -43,7 +43,7 @@ ZmqSignalSource::ZmqSignalSource(const ConfigurationInterface* configuration, { LOG(INFO) << "Connecting to ZMQ pub at " << endpoint; // work around gnuradio interface const-deficiency - d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, endpoint.data(), timeout_ms, pass_tags, hwm); + d_source_block = gr::zeromq::sub_source::make(d_item_size, vlen, const_cast(endpoint.data()), timeout_ms, pass_tags, hwm); // work around another bug. GNU Radio passes tags through the ZMQ block // unconditionally if pass_tags is true, but that flag controls protocol more From dd4478135a1297d3d691f4c470dffed3d95f90e4 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 14:21:07 +0100 Subject: [PATCH 2/4] Remove useless casts --- src/algorithms/libs/gps_l2c_signal_replica.cc | 2 +- src/algorithms/libs/gps_l5_signal_replica.cc | 4 ++-- src/tests/unit-tests/arithmetic/complex_carrier_test.cc | 4 ++-- ...galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ..._e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ..._pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc | 2 +- ...eo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc | 2 +- ...alileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc | 8 ++++---- .../acquisition/galileo_e5b_pcps_acquisition_test.cc | 2 +- .../acquisition/galileo_e6_pcps_acquisition_test.cc | 2 +- .../gps_l1_ca_pcps_acquisition_gsoc2013_test.cc | 2 +- .../gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc | 2 +- .../gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc | 2 +- .../gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc | 2 +- .../signal-processing-blocks/adapter/adapter_test.cc | 4 ++-- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/algorithms/libs/gps_l2c_signal_replica.cc b/src/algorithms/libs/gps_l2c_signal_replica.cc index 5be9e632e..c536be0af 100644 --- a/src/algorithms/libs/gps_l2c_signal_replica.cc +++ b/src/algorithms/libs/gps_l2c_signal_replica.cc @@ -24,7 +24,7 @@ uint32_t gps_l2c_m_shift(uint32_t x) { - return static_cast((x >> 1U) xor ((x & 1U) * 0445112474U)); + return ((x >> 1U) xor ((x & 1U) * 0445112474U)); } diff --git a/src/algorithms/libs/gps_l5_signal_replica.cc b/src/algorithms/libs/gps_l5_signal_replica.cc index 75ce0c9bc..09a6ac798 100644 --- a/src/algorithms/libs/gps_l5_signal_replica.cc +++ b/src/algorithms/libs/gps_l5_signal_replica.cc @@ -210,7 +210,7 @@ void gps_l5i_code_gen_complex_sampled(own::span> dest, uint3 // === Digitizing ================================================== // --- Make index array to read L5 code values --------------------- - codeValueIndex = static_cast(std::ceil(ts * static_cast(i + 1.0F) / tc)) - 1; + codeValueIndex = static_cast(std::ceil(ts * (i + 1.0F) / tc)) - 1; // --- Make the digitized version of the L5I code ------------------ if (i == samplesPerCode - 1) @@ -282,7 +282,7 @@ void gps_l5q_code_gen_complex_sampled(own::span> dest, uint3 // === Digitizing ================================================== // --- Make index array to read L5 code values --------------------- - codeValueIndex = static_cast(std::ceil(ts * static_cast(i + 1.0F) / tc)) - 1; + codeValueIndex = static_cast(std::ceil(ts * (i + 1.0F) / tc)) - 1; // --- Make the digitized version of the L5Q code ------------------ if (i == samplesPerCode - 1) diff --git a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc index 88ab2d6d9..19a4ba37c 100644 --- a/src/tests/unit-tests/arithmetic/complex_carrier_test.cc +++ b/src/tests/unit-tests/arithmetic/complex_carrier_test.cc @@ -32,7 +32,7 @@ TEST(ComplexCarrierTest, StandardComplexImplementation) auto* output = new std::complex[FLAGS_size_carrier_test]; const double _f = 2000.0; const double _fs = 2000000.0; - const auto phase_step = static_cast((TWO_PI * _f) / _fs); + const auto phase_step = (TWO_PI * _f) / _fs; double phase = 0.0; std::chrono::time_point start, end; @@ -72,7 +72,7 @@ TEST(ComplexCarrierTest, C11ComplexImplementation) std::vector> output(FLAGS_size_carrier_test); const double _f = 2000.0; const double _fs = 2000000.0; - const auto phase_step = static_cast((TWO_PI * _f) / _fs); + const auto phase_step = (TWO_PI * _f) / _fs; double phase = 0.0; std::chrono::time_point start, end; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index 8dbc5a45d..103778f60 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -387,7 +387,7 @@ void GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (static_cast(gnss_synchro.Acq_delay_samples) - 5) * 1023.0 / static_cast(fs_in * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (static_cast(gnss_synchro.Acq_delay_samples) - 5) * 1023.0 / (fs_in * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index 380f3bcb9..db50b891d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -387,7 +387,7 @@ void GalileoE1PcpsCccwsrAmbiguousAcquisitionTest::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index 991896a5c..5204b859b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -501,7 +501,7 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 4ab73ca01..093121afa 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -389,7 +389,7 @@ void GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 07d909d84..d90e8b0e9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -467,19 +467,19 @@ void GalileoE5aPcpsAcquisitionGSoC2014GensourceTest::process_message() switch (sat) { case 0: - delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); break; case 1: - delay_error_chips = std::abs(static_cast(expected_delay_chips1) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips1) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz1 - gnss_synchro.Acq_doppler_hz); break; case 2: - delay_error_chips = std::abs(static_cast(expected_delay_chips2) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips2) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz2 - gnss_synchro.Acq_doppler_hz); break; case 3: - delay_error_chips = std::abs(static_cast(expected_delay_chips3) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + delay_error_chips = std::abs(static_cast(expected_delay_chips3) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); doppler_error_hz = std::abs(expected_doppler_hz3 - gnss_synchro.Acq_doppler_hz); break; default: // case 3 diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc index 27dab121a..c74b99d29 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5b_pcps_acquisition_test.cc @@ -264,7 +264,7 @@ void GalileoE5bPcpsAcquisitionTest::process_message() { if (message == 1) { - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 10230.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); // The term -5 is here to correct the additional delay introduced by the FIR filter /* diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc index 82cfb7c98..497ced58f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e6_pcps_acquisition_test.cc @@ -264,7 +264,7 @@ void GalileoE6PcpsAcquisitionTest::process_message() { if (message == 1) { - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * GALILEO_E6_B_CODE_LENGTH_CHIPS / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * GALILEO_E6_B_CODE_LENGTH_CHIPS / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); // The term -5 is here to correct the additional delay introduced by the FIR filter /* diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index 2c2191f1e..70015c2d5 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -388,7 +388,7 @@ void GpsL1CaPcpsAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc index 7e4ef8df8..40f735c05 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc @@ -388,7 +388,7 @@ void GpsL1CaPcpsOpenClAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index 21ff4678e..92a8e19ff 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -490,7 +490,7 @@ void GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index a8e988210..20e737c94 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -382,7 +382,7 @@ void GpsL1CaPcpsTongAcquisitionGSoC2013Test::process_message() detection_counter++; // The term -5 is here to correct the additional delay introduced by the FIR filter - double delay_error_chips = std::abs(static_cast(expected_delay_chips) - static_cast(gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (gnss_synchro.Acq_delay_samples - 5) * 1023.0 / (static_cast(fs_in) * 1e-3)); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); mse_delay += std::pow(delay_error_chips, 2); 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 26ff99a38..68b3d6a3d 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 @@ -347,9 +347,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), iSample.real()); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), iSample.imag()); i++; } } From b751b4b8a1232fa8284f95a7cccbe74214a51262 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 14:23:30 +0100 Subject: [PATCH 3/4] Remove useless casts --- .../signal-processing-blocks/adapter/adapter_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 68b3d6a3d..f4c6aaa44 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 @@ -373,9 +373,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), iSample.real()); i++; - EXPECT_EQ(input_data_shorts.at(i), static_cast(iSample.imag())); + EXPECT_EQ(input_data_shorts.at(i), iSample.imag()); i++; } } From 0a438ec7266433c3771059c787961fa21b688187 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 16:08:56 +0100 Subject: [PATCH 4/4] Avoid shadowed variables --- docs/CHANGELOG.md | 5 +++++ src/algorithms/PVT/libs/rinex_printer.cc | 1 - .../telemetry_decoder/libs/viterbi_decoder_sbas.cc | 7 ++++--- .../telemetry_decoder/libs/viterbi_decoder_sbas.h | 2 +- src/core/system_parameters/galileo_has_data.cc | 8 ++++---- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index b17d9b6f7..162df725f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -31,6 +31,11 @@ All notable changes to GNSS-SDR will be documented in this file. - `geohash`, an [encoded geographic location](https://en.wikipedia.org/wiki/Geohash). +### Improvements in Maintainability + +- Removed useless casts and shadowed variables, improving source code + readability. + ### Improvements in Portability: - Updated local `cpu_features` library to v0.9.0. diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index 516403dbb..8f3042830 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -11309,7 +11309,6 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga it++) { lineObs.clear(); - const auto satsys_gal = satelliteSystem.find("Galileo"); if (satsys_gal != satelliteSystem.cend()) { lineObs += satsys_gal->second; diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc index 116215ad0..7972e708c 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.cc @@ -423,9 +423,10 @@ int Viterbi_Decoder_Sbas::parity_counter(int symbol, int length) // prev helper class -Viterbi_Decoder_Sbas::Prev::Prev(int states, int t) : num_states(states), - t(t), - refcount(1) +Viterbi_Decoder_Sbas::Prev::Prev(int states, + int tt) : num_states(states), + t(tt), + refcount(1) { state = std::vector(num_states); v_bit = std::vector(num_states); diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h index cf119e7fe..0f0a213df 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder_sbas.h @@ -56,7 +56,7 @@ private: { public: int num_states; - Prev(int states, int t); + Prev(int states, int tt); Prev(const Prev& prev); Prev& operator=(const Prev& other); ~Prev(); diff --git a/src/core/system_parameters/galileo_has_data.cc b/src/core/system_parameters/galileo_has_data.cc index 2e722f64a..cf52b9a99 100644 --- a/src/core/system_parameters/galileo_has_data.cc +++ b/src/core/system_parameters/galileo_has_data.cc @@ -602,10 +602,10 @@ float Galileo_HAS_data::get_code_bias_m(const std::string& signal, int PRN) cons if (!code_bias.empty() && !targeted_system.empty()) { std::vector systems = this->get_systems_string(); - auto Nsys = systems.size(); + auto Nsys_ = systems.size(); auto nsys_index = std::distance(systems.cbegin(), std::find(systems.cbegin(), systems.cend(), targeted_system)); - if (static_cast(nsys_index) < Nsys) + if (static_cast(nsys_index) < Nsys_) { std::vector signals = get_signals_in_mask(static_cast(nsys_index)); auto sig_index = std::distance(signals.cbegin(), std::find(signals.cbegin(), signals.cend(), signal)); @@ -678,10 +678,10 @@ float Galileo_HAS_data::get_phase_bias_cycle(const std::string& signal, int PRN) if (!phase_bias.empty() && !targeted_system.empty()) { std::vector systems = this->get_systems_string(); - auto Nsys = systems.size(); + auto Nsys_ = systems.size(); auto nsys_index = std::distance(systems.cbegin(), std::find(systems.cbegin(), systems.cend(), targeted_system)); - if (static_cast(nsys_index) < Nsys) + if (static_cast(nsys_index) < Nsys_) { std::vector signals = get_signals_in_mask(static_cast(nsys_index)); auto sig_index = std::distance(signals.cbegin(), std::find(signals.cbegin(), signals.cend(), signal));