diff --git a/lib/include/srslte/adt/accumulators.h b/lib/include/srslte/adt/accumulators.h index 86a652fd7..4c89653d6 100644 --- a/lib/include/srslte/adt/accumulators.h +++ b/lib/include/srslte/adt/accumulators.h @@ -71,12 +71,12 @@ struct sliding_window { next_idx -= window.size(); } } - size_t size() const { return window.size(); } + std::size_t size() const { return window.size(); } const T& oldest() const { return window[(next_idx + size() - 1) % size()]; } - T& operator[](size_t i) { return window[i]; } - const T& operator[](size_t i) const { return window[i]; } + T& operator[](std::size_t i) { return window[i]; } + const T& operator[](std::size_t i) const { return window[i]; } std::vector window; - size_t next_idx = 0; + std::size_t next_idx = 0; }; } // namespace detail @@ -92,7 +92,7 @@ struct sliding_sum : private detail::sliding_window { T value() const { T ret = 0; - for (size_t i = 0; i < size(); ++i) { + for (std::size_t i = 0; i < size(); ++i) { ret += (*this)[i]; } return ret; @@ -111,23 +111,23 @@ private: template struct null_sliding_average { - static constexpr T null_value = std::numeric_limits::max(); - null_sliding_average(uint32_t N) : window(N, null_value) {} + null_sliding_average(uint32_t N) : window(N, null_value()) {} void push(T sample) { window.push(sample); } - void push_hole() { window.push(null_value); } + void push_hole() { window.push(null_value()); } T value() const { T ret = 0; uint32_t count = 0; - for (size_t i = 0; i < window.size(); ++i) { - if (window[i] != null_value) { + for (std::size_t i = 0; i < window.size(); ++i) { + if (window[i] != null_value()) { ret += window[i]; count++; } } - return (count == 0) ? null_value : ret / count; + return (count == 0) ? null_value() : ret / count; } + static constexpr T null_value() { return std::numeric_limits::max(); } private: detail::sliding_window window; diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h index 3f07f0b7f..ae01069cd 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/tpc.h @@ -69,7 +69,7 @@ public: } // Enqueue pending SNR measurement - if (pending_snr == snr_avg.null_value) { + if (pending_snr == snr_avg.null_value()) { acc_pusch_tpc_values += win_pusch_tpc_values.oldest(); acc_pucch_tpc_values += win_pusch_tpc_values.oldest(); } else { @@ -77,7 +77,7 @@ public: acc_pusch_tpc_values = 0; } snr_avg.push(pending_snr); - pending_snr = snr_avg.null_value; + pending_snr = snr_avg.null_value(); // Enqueue PUSCH/PUCCH TPC sent in last TTI (zero for both Delta_PUSCH/Delta_PUCCH=0 and TPC not sent) win_pusch_tpc_values.push(pending_pusch_tpc); @@ -101,7 +101,7 @@ public: pending_pusch_tpc = (max_prbs_cached == nof_prb) ? 1 : (last_phr < 0 ? -1 : 0); pusch_phr_flag = true; } - } else if (snr_avg.value() != snr_avg.null_value) { + } else if (snr_avg.value() != snr_avg.null_value()) { // target SINR is finite and there is power headroom float diff = target_snr_dB - snr_avg.value(); diff -= win_pusch_tpc_values.value() + acc_pusch_tpc_values; @@ -134,7 +134,7 @@ public: pending_pucch_tpc = (max_prbs_cached == nof_prb) ? 1 : (last_phr < 0 ? -1 : 0); pucch_phr_flag = true; } - } else if (snr_avg.value() != snr_avg.null_value) { + } else if (snr_avg.value() != snr_avg.null_value()) { // target SINR is finite and there is power headroom float diff = target_snr_dB - snr_avg.value(); diff -= win_pucch_tpc_values.value() + acc_pucch_tpc_values; @@ -162,7 +162,7 @@ private: srslte::sliding_sum win_pusch_tpc_values, win_pucch_tpc_values; uint32_t max_prbs_cached = 100; int pending_pusch_tpc = 0, pending_pucch_tpc = 0; - float pending_snr = srslte::null_sliding_average::null_value; + float pending_snr = srslte::null_sliding_average::null_value(); int acc_pusch_tpc_values = 0, acc_pucch_tpc_values = 0; int last_phr = undefined_phr; bool pusch_phr_flag = false, pucch_phr_flag = false; diff --git a/srsenb/test/mac/sched_ca_test.cc b/srsenb/test/mac/sched_ca_test.cc index 137b75499..ae22964f3 100644 --- a/srsenb/test/mac/sched_ca_test.cc +++ b/srsenb/test/mac/sched_ca_test.cc @@ -75,7 +75,7 @@ struct test_scell_activation_params { int test_scell_activation(test_scell_activation_params params) { - std::array prb_list = {6, 15, 25, 50, 75, 100}; + std::array prb_list{6, 15, 25, 50, 75, 100}; /* Simulation Configuration Arguments */ uint32_t nof_prb = prb_list[std::uniform_int_distribution{0, 5}(get_rand_gen())];