From 0a438ec7266433c3771059c787961fa21b688187 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Wed, 15 Nov 2023 16:08:56 +0100 Subject: [PATCH] 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));