From 4204321fdecb0a572726572349fcb395b93331bb Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 19 Feb 2019 17:04:34 +0100 Subject: [PATCH] fix uninitialised variables in enb during startup --- srsenb/hdr/mac/mac.h | 1 + srsenb/hdr/phy/phch_common.h | 2 -- srsenb/src/mac/mac.cc | 13 +++++++------ srsenb/src/mac/scheduler.cc | 3 ++- srsenb/src/phy/phch_common.cc | 27 ++++++++++++++++----------- srsenb/src/phy/txrx.cc | 2 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/srsenb/hdr/mac/mac.h b/srsenb/hdr/mac/mac.h index 8aee46560..edbed523a 100644 --- a/srsenb/hdr/mac/mac.h +++ b/srsenb/hdr/mac/mac.h @@ -63,6 +63,7 @@ class mac { public: mac(); + ~mac(); bool init(mac_args_t *args, srslte_cell_t *cell, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h); void stop(); diff --git a/srsenb/hdr/phy/phch_common.h b/srsenb/hdr/phy/phch_common.h index 47e1add77..4d3ff550b 100644 --- a/srsenb/hdr/phy/phch_common.h +++ b/srsenb/hdr/phy/phch_common.h @@ -74,8 +74,6 @@ typedef struct { class phch_common { public: - - phch_common(uint32_t nof_workers); ~phch_common(); diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index 48e02620b..5e3babcaa 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -63,6 +63,13 @@ mac::mac() : timers_db(128), timers_thread(&timers_db), tti(0), last_rnti(0), bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx)); bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx)); bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx)); + pthread_rwlock_init(&rwlock, NULL); +} + +mac::~mac() +{ + pthread_rwlock_unlock(&rwlock); + pthread_rwlock_destroy(&rwlock); } bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, rlc_interface_mac *rlc, rrc_interface_mac *rrc, srslte::log *log_h_) @@ -97,8 +104,6 @@ bool mac::init(mac_args_t *args_, srslte_cell_t *cell_, phy_interface_mac *phy, reset(); - pthread_rwlock_init(&rwlock, NULL); - started = true; } @@ -120,9 +125,6 @@ void mac::stop() started = false; timers_thread.stop(); pdu_process_thread.stop(); - - pthread_rwlock_unlock(&rwlock); - pthread_rwlock_destroy(&rwlock); } // Implement Section 5.9 @@ -137,7 +139,6 @@ void mac::reset() /* Setup scheduler */ scheduler.reset(); - } void mac::start_pcap(srslte::mac_pcap* pcap_) diff --git a/srsenb/src/mac/scheduler.cc b/srsenb/src/mac/scheduler.cc index 837546ec8..33f25d46f 100644 --- a/srsenb/src/mac/scheduler.cc +++ b/srsenb/src/mac/scheduler.cc @@ -61,10 +61,11 @@ sched::sched() : bc_aggr_level(0), rar_aggr_level(0), avail_rbg(0), P(0), start_ for (int i = 0; i < 3; i++) { bzero(rar_locations[i], sizeof(sched_ue::sched_dci_cce_t) * 10); } - reset(); pthread_rwlock_init(&rwlock, NULL); pthread_mutex_init(&sched_mutex, NULL); + + reset(); } sched::~sched() diff --git a/srsenb/src/phy/phch_common.cc b/srsenb/src/phy/phch_common.cc index 2323a7ab3..190b7ef76 100644 --- a/srsenb/src/phy/phch_common.cc +++ b/srsenb/src/phy/phch_common.cc @@ -42,16 +42,21 @@ using namespace asn1::rrc; namespace srsenb { -phch_common::phch_common(uint32_t max_workers) : tx_sem(max_workers) +phch_common::phch_common(uint32_t max_workers_) : + tx_sem(max_workers_), + sib13_configured(false), + mcch_configured(false), + radio(NULL), + mac(NULL), + is_first_tx(false), + is_first_of_burst(false), + pdsch_p_b(0), + max_workers(max_workers_), + nof_workers(0), + params() { - this->nof_workers = nof_workers; params.max_prach_offset_us = 20; - radio = NULL; - mac = NULL; - is_first_tx = false; - is_first_of_burst = false; - pdsch_p_b = 0; - this->max_workers = max_workers; + bzero(&pusch_cfg, sizeof(pusch_cfg)); bzero(&hopping_cfg, sizeof(hopping_cfg)); bzero(&pucch_cfg, sizeof(pucch_cfg)); @@ -68,9 +73,9 @@ phch_common::~phch_common() { } } -void phch_common::set_nof_workers(uint32_t nof_workers) +void phch_common::set_nof_workers(uint32_t nof_workers_) { - this->nof_workers = nof_workers; + nof_workers = nof_workers_; } void phch_common::reset() { @@ -301,7 +306,7 @@ bool phch_common::is_mcch_subframe(subframe_cfg_t *cfg, uint32_t phy_tti) sfn = phy_tti/10; sf = phy_tti%10; - if(sib13_configured) { + if (sib13_configured) { mbsfn_area_info_r9_s* area_info = &mbsfn.mbsfn_area_info; offset = area_info->mcch_cfg_r9.mcch_offset_r9; diff --git a/srsenb/src/phy/txrx.cc b/srsenb/src/phy/txrx.cc index b1455936e..d3c8a620b 100644 --- a/srsenb/src/phy/txrx.cc +++ b/srsenb/src/phy/txrx.cc @@ -78,7 +78,7 @@ void txrx::run_thread() { phch_worker *worker = NULL; cf_t *buffer[SRSLTE_MAX_PORTS] = {NULL}; - srslte_timestamp_t rx_time, tx_time; + srslte_timestamp_t rx_time = {}, tx_time = {}; uint32_t sf_len = SRSLTE_SF_LEN_PRB(worker_com->cell.nof_prb); float samp_rate = srslte_sampling_freq_hz(worker_com->cell.nof_prb);