diff --git a/lib/src/phy/common/phy_common.c b/lib/src/phy/common/phy_common.c index 062a001db..11dede0e3 100644 --- a/lib/src/phy/common/phy_common.c +++ b/lib/src/phy/common/phy_common.c @@ -731,8 +731,19 @@ uint32_t srslte_print_check(char* s, size_t max_len, uint32_t cur_len, const cha if (cur_len < max_len - 1) { va_list args; va_start(args, format); - cur_len += vsnprintf(&s[cur_len], max_len - cur_len, format, args); + size_t n = max_len - cur_len; + int ret = vsnprintf(&s[cur_len], n, format, args); va_end(args); + + if (ret >= 0 && ret < n) { + // Notice that only when this returned value is non-negative and less than n, the string has been completely + // written. + cur_len += ret; + } else { + // Formatting error detected + ERROR("Formatting error when printing string\n"); + exit(-1); + } } else { ERROR("Buffer full when printing string\n"); exit(-1); diff --git a/srsenb/hdr/phy/cc_worker.h b/srsenb/hdr/phy/cc_worker.h index e3d51bccd..8ddda152d 100644 --- a/srsenb/hdr/phy/cc_worker.h +++ b/srsenb/hdr/phy/cc_worker.h @@ -100,14 +100,14 @@ private: class ue { public: - ue(uint16_t rnti, phy_common* phy) + ue(uint16_t id, phy_common* phy) { // Copy common configuartion ul_cfg = phy->ul_cfg_com; dl_cfg = phy->dl_cfg_com; // Fill RNTI - this->rnti = rnti; + rnti = id; dl_cfg.pdsch.rnti = rnti; ul_cfg.pusch.rnti = rnti; ul_cfg.pucch.rnti = rnti; diff --git a/srsenb/src/phy/cc_worker.cc b/srsenb/src/phy/cc_worker.cc index c40272d5b..165b9c920 100644 --- a/srsenb/src/phy/cc_worker.cc +++ b/srsenb/src/phy/cc_worker.cc @@ -323,9 +323,8 @@ void cc_worker::work_ul(srslte_ul_sf_cfg_t* ul_sf_cfg, stack_interface_phy_lte:: ul_sf = *ul_sf_cfg; log_h->step(ul_sf.tti); - for (auto& iter : ue_db) { - auto rnti = (uint16_t)iter.first; - ue_db[rnti]->is_grant_available = false; + for (auto& ue : ue_db) { + ue.second->is_grant_available = false; } // Process UL signal @@ -723,11 +722,9 @@ uint32_t cc_worker::get_metrics(phy_metrics_t metrics[ENB_METRICS_MAX_USERS]) { std::lock_guard lock(mutex); uint32_t cnt = 0; - for (auto& iter : ue_db) { - ue* u = iter.second; - uint16_t rnti = iter.first; - if (SRSLTE_RNTI_ISUSER(rnti) && cnt < ENB_METRICS_MAX_USERS) { - u->metrics_read(&metrics[cnt]); + for (auto& ue : ue_db) { + if (SRSLTE_RNTI_ISUSER(ue.first) && cnt < ENB_METRICS_MAX_USERS) { + ue.second->metrics_read(&metrics[cnt]); cnt++; } } @@ -777,16 +774,16 @@ int cc_worker::read_ce_arg(float* ce_arg) int cc_worker::read_pusch_d(cf_t* pdsch_d) { - int nof_re = 400; // enb_ul.ul_cfg.pusch.nbits.nof_re + int nof_re = enb_ul.pusch.max_re; memcpy(pdsch_d, enb_ul.pusch.d, nof_re * sizeof(cf_t)); return nof_re; } int cc_worker::read_pucch_d(cf_t* pdsch_d) { - int nof_re = SRSLTE_PUCCH_MAX_BITS / 2; // enb_ul.ul_cfg.pusch.nbits.nof_re + int nof_re = SRSLTE_PUCCH_MAX_BITS / 2; memcpy(pdsch_d, enb_ul.pucch.z_tmp, nof_re * sizeof(cf_t)); return nof_re; } -} // namespace srsenb \ No newline at end of file +} // namespace srsenb