More COverity Fixes

master
Xavier Arteaga 7 years ago
parent 99ef760b6f
commit 20934a4f89

@ -42,13 +42,26 @@
namespace srsenb { namespace srsenb {
mac::mac() : timers_db(128), mac::mac() : timers_db(128), timers_thread(&timers_db), tti(0), last_rnti(0),
timers_thread(&timers_db), rar_pdu_msg(sched_interface::MAX_RAR_LIST), rar_payload(),
rar_pdu_msg(sched_interface::MAX_RAR_LIST),
pdu_process_thread(this) pdu_process_thread(this)
{ {
started = false; started = false;
pcap = NULL; pcap = NULL;
phy_h = NULL;
rlc_h = NULL;
rrc_h = NULL;
log_h = NULL;
bzero(&locations, sizeof(locations));
bzero(&cell, sizeof(cell));
bzero(&args, sizeof(args));
bzero(&pending_rars, sizeof(pending_rars));
bzero(&bcch_dlsch_payload, sizeof(bcch_dlsch_payload));
bzero(&pcch_payload_buffer, sizeof(pcch_payload_buffer));
bzero(&bcch_softbuffer_tx, sizeof(bcch_softbuffer_tx));
bzero(&pcch_softbuffer_tx, sizeof(pcch_softbuffer_tx));
bzero(&rar_softbuffer_tx, sizeof(rar_softbuffer_tx));
} }
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_) 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_)
@ -722,8 +735,7 @@ void mac::timer_thread::tti_clock()
* DEMU unit * DEMU unit
* *
*******************************************************/ *******************************************************/
mac::pdu_process::pdu_process(pdu_process_handler *h) mac::pdu_process::pdu_process(pdu_process_handler *h) : running(false) {
{
handler = h; handler = h;
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL); pthread_cond_init(&cvar, NULL);

@ -18,10 +18,26 @@ namespace srsenb {
* Initialization and sched configuration functions * Initialization and sched configuration functions
* *
*******************************************************/ *******************************************************/
sched::sched() sched::sched() : bc_aggr_level(0), rar_aggr_level(0), avail_rbg(0), P(0), start_rbg(0), si_n_rbg(0), rar_n_rb(0),
{ nof_rbg(0), sf_idx(0), sfn(0), current_cfi(0) {
current_tti = 0; current_tti = 0;
log_h = NULL; log_h = NULL;
dl_metric = NULL;
ul_metric = NULL;
rrc = NULL;
bzero(&cfg, sizeof(cfg));
bzero(&regs, sizeof(regs));
bzero(&used_cce, sizeof(used_cce));
bzero(&sched_cfg, sizeof(sched_cfg));
bzero(&common_locations, sizeof(common_locations));
bzero(&pdsch_re, sizeof(pdsch_re));
bzero(&mutex, sizeof(mutex));
for (int i = 0; i < 3; i++) {
bzero(rar_locations[i], sizeof(sched_ue::sched_dci_cce_t) * 10);
}
pthread_mutex_init(&mutex, NULL); pthread_mutex_init(&mutex, NULL);
reset(); reset();
} }
@ -80,7 +96,10 @@ int sched::cell_cfg(sched_interface::cell_cfg_t* cell_cfg)
memcpy(&cfg, cell_cfg, sizeof(sched_interface::cell_cfg_t)); memcpy(&cfg, cell_cfg, sizeof(sched_interface::cell_cfg_t));
// Get DCI locations // Get DCI locations
srslte_regs_init(&regs, cfg.cell); if (srslte_regs_init(&regs, cfg.cell)) {
Error("Getting DCI locations\n");
return SRSLTE_ERROR;
}
P = srslte_ra_type0_P(cfg.cell.nof_prb); P = srslte_ra_type0_P(cfg.cell.nof_prb);
si_n_rbg = 4/P; si_n_rbg = 4/P;

@ -49,9 +49,18 @@ namespace srsenb {
* *
*******************************************************/ *******************************************************/
sched_ue::sched_ue() sched_ue::sched_ue() : ue_idx(0), has_pucch(false), power_headroom(0), rnti(0), max_mcs_dl(0), max_mcs_ul(0),
fixed_mcs_ul(0), fixed_mcs_dl(0), phy_config_dedicated_enabled(false)
{ {
reset(); log_h = NULL;
bzero(&cell, sizeof(cell));
bzero(&lch, sizeof(lch));
bzero(&dci_locations, sizeof(dci_locations));
bzero(&dl_harq, sizeof(dl_harq));
bzero(&ul_harq, sizeof(ul_harq));
bzero(&dl_ant_info, sizeof(dl_ant_info));
reset();
} }
void sched_ue::set_cfg(uint16_t rnti_, sched_interface::ue_cfg_t *cfg_, sched_interface::cell_cfg_t *cell_cfg, void sched_ue::set_cfg(uint16_t rnti_, sched_interface::ue_cfg_t *cfg_, sched_interface::cell_cfg_t *cell_cfg,
@ -92,17 +101,21 @@ void sched_ue::set_cfg(uint16_t rnti_, sched_interface::ue_cfg_t *cfg_, sched_in
void sched_ue::reset() void sched_ue::reset()
{ {
bzero(&cfg, sizeof(sched_interface::ue_cfg_t)); bzero(&cfg, sizeof(sched_interface::ue_cfg_t));
sr = false; sr = false;
next_tpc_pusch = 1; next_tpc_pusch = 1;
next_tpc_pucch = 1; next_tpc_pucch = 1;
buf_mac = 0; buf_mac = 0;
buf_ul = 0; buf_ul = 0;
phy_config_dedicated_enabled = false; phy_config_dedicated_enabled = false;
dl_cqi = 1; dl_cqi = 1;
ul_cqi = 1; ul_cqi = 1;
dl_cqi_tti = 0; dl_cqi_tti = 0;
ul_cqi_tti = 0; ul_cqi_tti = 0;
cqi_request_tti = 0; dl_ri = 0;
dl_ri_tti = 0;
dl_pmi = 0;
dl_pmi_tti = 0;
cqi_request_tti = 0;
for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) { for (int i=0;i<SCHED_MAX_HARQ_PROC;i++) {
for(uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) { for(uint32_t tb = 0; tb < SRSLTE_MAX_TB; tb++) {
dl_harq[i].reset(tb); dl_harq[i].reset(tb);

@ -368,8 +368,7 @@ uint8_t* ue::generate_pdu(uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[s
{ {
uint8_t *ret = NULL; uint8_t *ret = NULL;
pthread_mutex_lock(&mutex); pthread_mutex_lock(&mutex);
if (rlc) if (rlc) {
{
mac_msg_dl.init_tx(tx_payload_buffer[tb_idx], grant_size, false); mac_msg_dl.init_tx(tx_payload_buffer[tb_idx], grant_size, false);
for (uint32_t i=0;i<nof_pdu_elems;i++) { for (uint32_t i=0;i<nof_pdu_elems;i++) {
if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) { if (pdu[i].lcid <= srslte::sch_subh::PHR_REPORT) {
@ -383,7 +382,6 @@ uint8_t* ue::generate_pdu(uint32_t tb_idx, sched_interface::dl_sched_pdu_t pdu[s
} else { } else {
std::cout << "Error ue not configured (must call config() first" << std::endl; std::cout << "Error ue not configured (must call config() first" << std::endl;
return NULL;
} }
pthread_mutex_unlock(&mutex); pthread_mutex_unlock(&mutex);

@ -35,6 +35,7 @@
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <string.h>
using namespace std; using namespace std;
@ -46,11 +47,11 @@ char const * const prefixes[2][9] =
{ "", "k", "M", "G", "T", "P", "E", "Z", "Y", }, { "", "k", "M", "G", "T", "P", "E", "Z", "Y", },
}; };
metrics_stdout::metrics_stdout() metrics_stdout::metrics_stdout() : started(false) ,do_print(false), metrics_report_period(0.0f),n_reports(10)
:started(false)
,do_print(false)
,n_reports(10)
{ {
enb_ = NULL;
bzero(&metrics_thread, sizeof(metrics_thread));
bzero(&metrics, sizeof(metrics));
} }
bool metrics_stdout::init(enb_metrics_interface *u, float report_period_secs) bool metrics_stdout::init(enb_metrics_interface *u, float report_period_secs)
@ -101,6 +102,8 @@ void metrics_stdout::metrics_thread_run()
void metrics_stdout::print_metrics() void metrics_stdout::print_metrics()
{ {
std::ios::fmtflags f(cout.flags()); // For avoiding Coverity defect: Not restoring ostream format
if(!do_print) if(!do_print)
return; return;
@ -157,7 +160,8 @@ void metrics_stdout::print_metrics()
if(metrics.rf.rf_error) { if(metrics.rf.rf_error) {
printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l); printf("RF status: O=%d, U=%d, L=%d\n", metrics.rf.rf_o, metrics.rf.rf_u, metrics.rf.rf_l);
} }
cout.flags(f); // For avoiding Coverity defect: Not restoring ostream format
} }
void metrics_stdout::print_disconnect() void metrics_stdout::print_disconnect()

@ -73,6 +73,11 @@ namespace srsenb {
phch_worker::phch_worker() phch_worker::phch_worker()
{ {
phy = NULL; phy = NULL;
bzero(&enb_dl, sizeof(enb_dl));
bzero(&enb_ul, sizeof(enb_ul));
bzero(&tx_time, sizeof(tx_time));
reset(); reset();
} }

@ -48,8 +48,11 @@ namespace srsenb {
phy::phy() : workers_pool(MAX_WORKERS), phy::phy() : workers_pool(MAX_WORKERS),
workers(MAX_WORKERS), workers(MAX_WORKERS),
workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS) workers_common(txrx::MUTEX_X_WORKER*MAX_WORKERS),
nof_workers(0)
{ {
radio_handler = NULL;
bzero(&prach_cfg, sizeof(prach_cfg));
} }
void phy::parse_config(phy_cfg_t* cfg) void phy::parse_config(phy_cfg_t* cfg)

@ -42,13 +42,13 @@ using namespace std;
namespace srsenb { namespace srsenb {
txrx::txrx() txrx::txrx() : tx_mutex_cnt(0), nof_tx_mutex(0), tti(0) {
{
running = false; running = false;
radio_h = NULL; radio_h = NULL;
log_h = NULL; log_h = NULL;
workers_pool = NULL; workers_pool = NULL;
worker_com = NULL; worker_com = NULL;
prach = NULL;
} }
bool txrx::init(srslte::radio* radio_h_, srslte::thread_pool* workers_pool_, phch_common* worker_com_, prach_worker *prach_, srslte::log* log_h_, uint32_t prio_) bool txrx::init(srslte::radio* radio_h_, srslte::thread_pool* workers_pool_, phch_common* worker_com_, prach_worker *prach_, srslte::log* log_h_, uint32_t prio_)

@ -553,61 +553,67 @@ void rrc::read_pdu_pcch(uint8_t *payload, uint32_t buffer_size)
void rrc::parse_ul_ccch(uint16_t rnti, byte_buffer_t *pdu) void rrc::parse_ul_ccch(uint16_t rnti, byte_buffer_t *pdu)
{ {
uint16_t old_rnti = 0; uint16_t old_rnti = 0;
LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg; if (pdu) {
bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT)); LIBLTE_RRC_UL_CCCH_MSG_STRUCT ul_ccch_msg;
bzero(&ul_ccch_msg, sizeof(LIBLTE_RRC_UL_CCCH_MSG_STRUCT));
srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes*8);
bit_buf.N_bits = pdu->N_bytes*8; srslte_bit_unpack_vector(pdu->msg, bit_buf.msg, pdu->N_bytes * 8);
liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT*)&bit_buf, &ul_ccch_msg); bit_buf.N_bits = pdu->N_bytes * 8;
liblte_rrc_unpack_ul_ccch_msg((LIBLTE_BIT_MSG_STRUCT *) &bit_buf, &ul_ccch_msg);
rrc_log->info_hex(pdu->msg, pdu->N_bytes,
"SRB0 - Rx: %s", rrc_log->info_hex(pdu->msg, pdu->N_bytes,
liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]); "SRB0 - Rx: %s",
liblte_rrc_ul_ccch_msg_type_text[ul_ccch_msg.msg_type]);
switch(ul_ccch_msg.msg_type) {
case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ: switch (ul_ccch_msg.msg_type) {
if (users.count(rnti)) { case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REQ:
users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req); if (users.count(rnti)) {
} else { users[rnti].handle_rrc_con_req(&ul_ccch_msg.msg.rrc_con_req);
rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti);
}
break;
case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ:
rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n",
ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti, ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id,
ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i, liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause]
);
if (users[rnti].is_idle()) {
old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti;
if (users.count(old_rnti)) {
rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti);
users[rnti].send_connection_reest_rej();
rem_user_thread(old_rnti);
} else { } else {
rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti); rrc_log->error("Received ConnectionSetup for rnti=0x%x without context\n", rnti);
users[rnti].send_connection_reest_rej();
} }
// remove temporal rnti break;
rem_user_thread(rnti); case LIBLTE_RRC_UL_CCCH_MSG_TYPE_RRC_CON_REEST_REQ:
} else { rrc_log->debug("rnti=0x%x, phyid=0x%x, smac=0x%x, cause=%s\n",
rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti); ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti,
} ul_ccch_msg.msg.rrc_con_reest_req.ue_id.phys_cell_id,
break; ul_ccch_msg.msg.rrc_con_reest_req.ue_id.short_mac_i,
default: liblte_rrc_con_reest_req_cause_text[ul_ccch_msg.msg.rrc_con_reest_req.cause]
rrc_log->error("UL CCCH message not recognised\n"); );
break; if (users[rnti].is_idle()) {
old_rnti = ul_ccch_msg.msg.rrc_con_reest_req.ue_id.c_rnti;
if (users.count(old_rnti)) {
rrc_log->error("Not supported: ConnectionReestablishment. Sending Connection Reject\n", old_rnti);
users[rnti].send_connection_reest_rej();
rem_user_thread(old_rnti);
} else {
rrc_log->error("Received ConnectionReestablishment for rnti=0x%x without context\n", old_rnti);
users[rnti].send_connection_reest_rej();
}
// remove temporal rnti
rem_user_thread(rnti);
} else {
rrc_log->error("Received ReestablishmentRequest from an rnti=0x%x not in IDLE\n", rnti);
}
break;
default:
rrc_log->error("UL CCCH message not recognised\n");
break;
}
pool->deallocate(pdu);
} }
pool->deallocate(pdu);
} }
void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, byte_buffer_t *pdu) void rrc::parse_ul_dcch(uint16_t rnti, uint32_t lcid, byte_buffer_t *pdu)
{ {
if (users.count(rnti)) { if (pdu) {
users[rnti].parse_ul_dcch(lcid, pdu); if (users.count(rnti)) {
} else { users[rnti].parse_ul_dcch(lcid, pdu);
rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti); } else {
rrc_log->error("Processing %s: Unkown rnti=0x%x\n", rb_id_text[lcid], rnti);
}
} }
} }
@ -1757,7 +1763,7 @@ int rrc::ue::cqi_allocate(uint32_t period, uint32_t *pmi_idx, uint32_t *n_pucch)
*pmi_idx = 318 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 318 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} else if (period == 64) { } else if (period == 64) {
*pmi_idx = 350 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 350 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} else if (period == 64) { } else if (period == 128) {
*pmi_idx = 414 + parent->cfg.cqi_cfg.sf_mapping[j_min]; *pmi_idx = 414 + parent->cfg.cqi_cfg.sf_mapping[j_min];
} }
} }

Loading…
Cancel
Save