From 837c5bdce5b0a1d7bd7512b52cc8174d14d46bab Mon Sep 17 00:00:00 2001 From: Francisco Date: Fri, 5 Mar 2021 14:03:32 +0000 Subject: [PATCH] clang tidy update. applied small fixes to warnings from clang-tidy --- .clang-tidy | 2 ++ .../stack/mac/sched_ue_ctrl/sched_ue_cell.h | 2 -- .../src/stack/mac/sched_phy_ch/sched_dci.cc | 15 +++++---- .../stack/mac/sched_ue_ctrl/sched_ue_cell.cc | 33 +++++++++---------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 99d622a7b..c5a75d316 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -20,6 +20,8 @@ Checks: '*,-fuchsia-*, -google-runtime-references,-google-readability-casting,-google-build-using-namespace, google-default-arguments,-cppcoreguidelines-pro-bounds-pointer-arithmetic, -cert-err58-cpp, + -misc-non-private-member-variables-in-classes,-altera-struct-pack-align,-readability-uppercase-literal-suffix, + -cppcoreguidelines-non-private-member-variables-in-classes, readability-identifier-naming' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h index fce2c340c..d2533f78f 100644 --- a/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h +++ b/srsenb/hdr/stack/mac/sched_ue_ctrl/sched_ue_cell.h @@ -72,8 +72,6 @@ struct sched_ue_cell { int fixed_mcs_ul = 0, fixed_mcs_dl = 0; private: - void enter_idle_st(); - srslog::basic_logger& logger; const sched_interface::ue_cfg_t* ue_cfg = nullptr; diff --git a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc index cdd5b7c9d..b9d2e4ab6 100644 --- a/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc +++ b/srsenb/src/stack/mac/sched_phy_ch/sched_dci.cc @@ -20,7 +20,7 @@ namespace srsenb { /// Compute max TBS based on max coderate int coderate_to_tbs(float max_coderate, uint32_t nof_re) { - return floorf(nof_re * max_coderate - 24); + return static_cast(floorf(nof_re * max_coderate - 24)); } /// Compute {mcs, tbs_idx} based on {max_tbs, nof_prb} @@ -72,9 +72,9 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, assert((not is_ul or not use_tbs_index_alt) && "UL cannot use Alt CQI Table"); assert((is_ul or not ulqam64_enabled) && "DL cannot use UL-QAM64 enable flag"); - float max_coderate = srslte_cqi_to_coderate(std::min(cqi + 1u, 15u), use_tbs_index_alt); + float max_coderate = srslte_cqi_to_coderate(std::min(cqi + 1U, 15U), use_tbs_index_alt); uint32_t max_Qm = (is_ul) ? (ulqam64_enabled ? 6 : 4) : (use_tbs_index_alt ? 8 : 6); - max_coderate = std::min(max_coderate, 0.930f * max_Qm); + max_coderate = std::min(max_coderate, 0.93F * max_Qm); int mcs = 0; float prev_max_coderate = 0; @@ -104,12 +104,12 @@ tbs_info compute_mcs_and_tbs(uint32_t nof_prb, // update max coderate based on mcs srslte_mod_t mod = (is_ul) ? srslte_ra_ul_mod_from_mcs(mcs) : srslte_ra_dl_mod_from_mcs(mcs, use_tbs_index_alt); uint32_t Qm = srslte_mod_bits_x_symbol(mod); - max_coderate = std::min(0.930f * Qm, max_coderate); + max_coderate = std::min(0.93F * Qm, max_coderate); if (coderate <= max_coderate) { // solution was found tbs_info tb; - tb.tbs_bytes = tbs / 8u; + tb.tbs_bytes = tbs / 8; tb.mcs = mcs; return tb; } @@ -138,10 +138,11 @@ tbs_info compute_min_mcs_and_tbs_from_required_bytes(uint32_t nof_prb, } // get maximum MCS that leads to tbs < req_bytes (used as max_tbs argument) - int mcs_min = 0, tbs_idx_min = 0; + int mcs_min = 0; + int tbs_idx_min = 0; // Note: we subtract -1 to required data to get an exclusive lower bound for maximum MCS. This works ok because // req_bytes * 8 is always even - if (compute_mcs_from_max_tbs(nof_prb, req_bytes * 8u - 1, max_mcs, is_ul, use_tbs_index_alt, mcs_min, tbs_idx_min) != + if (compute_mcs_from_max_tbs(nof_prb, req_bytes * 8U - 1, max_mcs, is_ul, use_tbs_index_alt, mcs_min, tbs_idx_min) != SRSLTE_SUCCESS) { // Failed to compute maximum MCS that leads to TBS < req bytes. MCS=0 is likely a valid solution tbs_info tb2 = compute_mcs_and_tbs(nof_prb, nof_re, cqi, 0, is_ul, ulqam64_enabled, use_tbs_index_alt); diff --git a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc index c4879434c..17cfaad96 100644 --- a/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc +++ b/srsenb/src/stack/mac/sched_ue_ctrl/sched_ue_cell.cc @@ -30,14 +30,16 @@ sched_ue_cell::sched_ue_cell(uint16_t rnti_, const sched_cell_params_t& cell_cfg tpc_fsm(cell_cfg->nof_prb(), cell_cfg->cfg.target_ul_sinr, cell_cfg->cfg.enable_phr_handling), fixed_mcs_dl(cell_cfg_.sched_cfg->pdsch_mcs), fixed_mcs_ul(cell_cfg_.sched_cfg->pusch_mcs), - current_tti(current_tti_) + current_tti(current_tti_), + max_aggr_level(cell_cfg_.sched_cfg->max_aggr_level >= 0 ? cell_cfg_.sched_cfg->max_aggr_level : 3) { - max_aggr_level = cell_cfg->sched_cfg->max_aggr_level >= 0 ? cell_cfg->sched_cfg->max_aggr_level : 3; clear_feedback(); } void sched_ue_cell::set_ue_cfg(const sched_interface::ue_cfg_t& ue_cfg_) { + static const std::array max_64qam_mcs{20, 24, 28}; + cfg_tti = current_tti; ue_cfg = &ue_cfg_; int prev_ue_cc_idx = ue_cc_idx; @@ -52,14 +54,13 @@ void sched_ue_cell::set_ue_cfg(const sched_interface::ue_cfg_t& ue_cfg_) } // set max mcs - max_mcs_ul = cell_cfg->sched_cfg->pusch_max_mcs >= 0 ? cell_cfg->sched_cfg->pusch_max_mcs : 28u; + max_mcs_ul = cell_cfg->sched_cfg->pusch_max_mcs >= 0 ? cell_cfg->sched_cfg->pusch_max_mcs : 28U; if (cell_cfg->cfg.enable_64qam) { - const uint32_t max_64qam_mcs[] = {20, 24, 28}; - max_mcs_ul = std::min(max_mcs_ul, max_64qam_mcs[(size_t)ue_cfg->support_ul64qam]); + max_mcs_ul = std::min(max_mcs_ul, max_64qam_mcs[(size_t)ue_cfg->support_ul64qam]); } - max_mcs_dl = cell_cfg->sched_cfg->pdsch_max_mcs >= 0 ? std::min(cell_cfg->sched_cfg->pdsch_max_mcs, 28) : 28u; + max_mcs_dl = cell_cfg->sched_cfg->pdsch_max_mcs >= 0 ? std::min(cell_cfg->sched_cfg->pdsch_max_mcs, 28) : 28U; if (ue_cfg->use_tbs_index_alt) { - max_mcs_dl = std::min(max_mcs_dl, 27u); + max_mcs_dl = std::min(max_mcs_dl, 27U); } // If new cell configuration, clear Cell HARQs @@ -185,20 +186,18 @@ false_position_method(int x1, int x2, YType y0, const Callable& f, const ErrorDe YType y3_1 = f(x3 - 1); if (not is_error(y3_1) and y3_1 < y0) { return std::make_tuple(x3 - 1, y3_1, x3, y3); - } else { - x3--; - y3 = y3_1; } + x3--; + y3 = y3_1; } else if (x3 == x1) { y3 = y1; // check if in frontier YType y3_1 = f(x3 + 1); if (not is_error(y3_1) and y3_1 >= y0) { return std::make_tuple(x3, y3, x3 + 1, y3_1); - } else { - x3++; - y3 = y3_1; } + x3++; + y3 = y3_1; } else { y3 = f(x3); if (is_error(y3) or y3 == y0) { @@ -288,10 +287,10 @@ int get_required_prb_dl(const sched_ue_cell& cell, }; std::tuple ret = false_position_method( - 1u, cell.cell_cfg->nof_prb(), (int)req_bytes, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); + 1U, cell.cell_cfg->nof_prb(), (int)req_bytes, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); int upper_tbs = std::get<3>(ret); uint32_t upper_nprb = std::get<2>(ret); - return (upper_tbs < 0) ? 0 : ((upper_tbs < (int)req_bytes) ? -1 : upper_nprb); + return (upper_tbs < 0) ? 0 : ((upper_tbs < (int)req_bytes) ? -1 : static_cast(upper_nprb)); } uint32_t get_required_prb_ul(const sched_ue_cell& cell, uint32_t req_bytes) @@ -306,10 +305,10 @@ uint32_t get_required_prb_ul(const sched_ue_cell& cell, uint32_t req_bytes) }; // find nof prbs that lead to a tbs just above req_bytes - int target_tbs = req_bytes + 4; + int target_tbs = static_cast(req_bytes) + 4; uint32_t max_prbs = std::min(cell.tpc_fsm.max_ul_prbs(), cell.cell_cfg->nof_prb()); std::tuple ret = - false_position_method(1u, max_prbs, target_tbs, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); + false_position_method(1U, max_prbs, target_tbs, compute_tbs_approx, [](int y) { return y == SRSLTE_ERROR; }); uint32_t req_prbs = std::get<2>(ret); while (!srslte_dft_precoding_valid_prb(req_prbs) && req_prbs < cell.cell_cfg->nof_prb()) { req_prbs++;