From 6bb0790cf142af25d3e6ad63528e90817722eb67 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Fri, 13 Sep 2019 15:06:20 +0200 Subject: [PATCH] Fix coverty issues (#652) --- lib/include/srslte/interfaces/rrc_interface_types.h | 1 + lib/src/asn1/rrc_asn1_utils.cc | 5 ++--- lib/test/asn1/rrc_asn1_test.cc | 2 +- srsenb/src/stack/rrc/rrc.cc | 1 + srsue/src/phy/phy.cc | 4 +++- srsue/src/stack/rrc/rrc.cc | 13 +++++++------ 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/include/srslte/interfaces/rrc_interface_types.h b/lib/include/srslte/interfaces/rrc_interface_types.h index 600852bb3..fdb4ebfcb 100644 --- a/lib/include/srslte/interfaces/rrc_interface_types.h +++ b/lib/include/srslte/interfaces/rrc_interface_types.h @@ -412,6 +412,7 @@ struct phy_cfg_t { { ZERO_OBJECT(ul_cfg); ZERO_OBJECT(dl_cfg); + ZERO_OBJECT(prach_cfg); set_defaults_common(); set_defaults_dedicated(); diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index 6a6256412..3c8196635 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -581,9 +581,8 @@ void set_phy_cfg_t_scell_config(phy_cfg_t* cfg, const asn1::rrc::scell_to_add_mo // Parse Transmission mode if (non_ul_cfg->ant_info_r10_present) { - asn1::rrc::ant_info_ded_r10_s::tx_mode_r10_e_::options tx_mode = non_ul_cfg->ant_info_r10.tx_mode_r10.value; - if ((srslte_tm_t)tx_mode < SRSLTE_TMINV) { - cfg->dl_cfg.tm = (srslte_tm_t)tx_mode; + if (non_ul_cfg->ant_info_r10.tx_mode_r10.to_number() < (uint8_t)SRSLTE_TMINV) { + cfg->dl_cfg.tm = (srslte_tm_t)non_ul_cfg->ant_info_r10.tx_mode_r10.to_number(); } else { fprintf(stderr, "Transmission mode (R10) %s is not supported\n", diff --git a/lib/test/asn1/rrc_asn1_test.cc b/lib/test/asn1/rrc_asn1_test.cc index 8936bb27e..033ec4229 100644 --- a/lib/test/asn1/rrc_asn1_test.cc +++ b/lib/test/asn1/rrc_asn1_test.cc @@ -66,7 +66,7 @@ void print_console(srsasn_logger_level_t log_level, void* ctx, const char* str) } struct TestLogger { - TestLogger(const std::string& layer_) : layer(layer_) {} + TestLogger(const std::string& layer_) : layer(layer_), last_level(LOG_LEVEL_INFO) {} void log(srsasn_logger_level_t log_level, const char* str) { last_level = log_level; diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index 483ab7ec5..53b27ed89 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -402,6 +402,7 @@ bool rrc::modify_ue_ctxt(uint16_t rnti, LIBLTE_S1AP_MESSAGE_UECONTEXTMODIFICATIO if (err) { // maybe pass a cause value? + pthread_mutex_unlock(&user_mutex); return false; } diff --git a/srsue/src/phy/phy.cc b/srsue/src/phy/phy.cc index bb56d15c4..4afb78b33 100644 --- a/srsue/src/phy/phy.cc +++ b/srsue/src/phy/phy.cc @@ -444,7 +444,7 @@ void phy::set_config(srslte::phy_cfg_t& config, uint32_t cc_idx, uint32_t earfcn if (cc_idx == 0) { prach_cfg = config.prach_cfg; - } else { + } else if (cell_info) { // If SCell does not share synchronism with PCell ... if (m->radio_idx > 0) { scell_sync.at(m->radio_idx - 1)->set_scell_cell(cc_idx, cell_info, earfcn); @@ -465,6 +465,8 @@ void phy::set_config(srslte::phy_cfg_t& config, uint32_t cc_idx, uint32_t earfcn common.scell_cfg[cc_idx].pci = cell_info->id; common.scell_cfg[cc_idx].configured = true; common.scell_cfg[cc_idx].enabled = false; + } else { + Error("Configuring Scell index %d but cell_info not provided\n", cc_idx); } } else { diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 59b125c69..9118af272 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -2446,6 +2446,11 @@ void rrc::apply_phy_scell_config(const asn1::rrc::scell_to_add_mod_r10_s* scell_ srslte_cell_t scell = {}; uint32_t earfcn = 0; + if (phy != nullptr) { + rrc_log->info("RRC not initialized. Skipping PHY config.\n"); + return; + } + // Initialise default parameters from primary cell phy->get_current_cell(&scell, &earfcn); @@ -2462,18 +2467,14 @@ void rrc::apply_phy_scell_config(const asn1::rrc::scell_to_add_mod_r10_s* scell_ scell.nof_prb = rr_cfg->non_ul_cfg_r10.dl_bw_r10.to_number(); scell.nof_ports = rr_cfg->non_ul_cfg_r10.ant_info_common_r10.ant_ports_count.to_number(); scell.phich_length = (srslte_phich_length_t)rr_cfg->non_ul_cfg_r10.phich_cfg_r10.phich_dur.value; - scell.phich_resources = (srslte_phich_r_t)rr_cfg->non_ul_cfg_r10.phich_cfg_r10.phich_res.value; + scell.phich_resources = (srslte_phich_r_t)rr_cfg->non_ul_cfg_r10.phich_cfg_r10.phich_res.to_number(); } // Initialize scell config with pcell cfg srslte::phy_cfg_t scell_phy_cfg = current_phy_cfg; set_phy_cfg_t_scell_config(&scell_phy_cfg, scell_config); - if (phy != nullptr) { - phy->set_config(scell_phy_cfg, scell_config->s_cell_idx_r10, earfcn, &scell); - } else { - rrc_log->info("RRC not initialized. Skipping PHY config.\n"); - } + phy->set_config(scell_phy_cfg, scell_config->s_cell_idx_r10, earfcn, &scell); } void rrc::log_mac_config_dedicated()