More Coverity fixes

master
Xavier Arteaga 7 years ago
parent cfd7e4b2a5
commit 99ef760b6f

@ -180,8 +180,8 @@ private:
int build_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_retx_t retx);
int build_data_pdu(uint8_t *payload, uint32_t nof_bytes);
void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header);
void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header);
void handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header);
void handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header);
void handle_control_pdu(uint8_t *payload, uint32_t nof_bytes);
void reassemble_rx_sdus();

@ -90,6 +90,7 @@ uint32_t srslte_sch_find_Ioffset_cqi(float beta) {
int srslte_sch_init(srslte_sch_t *q) {
int ret = SRSLTE_ERROR_INVALID_INPUTS;
if (q) {
ret = SRSLTE_ERROR;
bzero(q, sizeof(srslte_sch_t));
if (srslte_crc_init(&q->crc_tb, SRSLTE_LTE_CRC24A, 24)) {
@ -754,6 +755,10 @@ int srslte_ulsch_uci_encode(srslte_sch_t *q,
uint32_t nb_q = cfg->nbits.nof_bits;
uint32_t Qm = cfg->grant.Qm;
if (Qm == 0) {
return SRSLTE_ERROR_INVALID_INPUTS;
}
if (uci_data.uci_ri_len > 0) {
float beta = beta_ri_offset[cfg->uci_cfg.I_offset_ri];
if (cfg->cb_segm.tbs == 0) {

@ -178,21 +178,10 @@ int main(int argc, char **argv) {
goto quit;
}
switch(mimo_type) {
case SRSLTE_MIMO_TYPE_SINGLE_ANTENNA:
if (mimo_type == SRSLTE_MIMO_TYPE_SINGLE_ANTENNA) {
cell.nof_ports = 1;
break;
case SRSLTE_MIMO_TYPE_SPATIAL_MULTIPLEX:
case SRSLTE_MIMO_TYPE_CDD:
if (nof_rx_antennas < 2) {
ERROR("At least two receiving antennas are required");
goto quit;
}
case SRSLTE_MIMO_TYPE_TX_DIVERSITY:
default:
} else {
cell.nof_ports = 2;
break;
}
srslte_ra_dl_dci_t dci;
@ -250,7 +239,7 @@ int main(int argc, char **argv) {
for (i=0;i<SRSLTE_MAX_PORTS;i++) {
for (j = 0; j < SRSLTE_MAX_PORTS; j++) {
ce[i][j] = srslte_vec_malloc(sizeof(cf_t) * NOF_CE_SYMBOLS);
if (!ce[i]) {
if (!ce[i][j]) {
perror("srslte_vec_malloc");
goto quit;
}

@ -176,8 +176,8 @@ int main(int argc, char **argv) {
srslte_rf_set_rx_freq(&rf, uhd_freq);
srslte_rf_set_tx_freq(&rf, uhd_freq);
if (srate > 1e6) {
if (30720%((int) srate/1000) == 0) {
if (srate > 1e6 && (srate/1000) > 0) {
if (30720%(srate/1000) == 0) {
srslte_rf_set_master_clock_rate(&rf, 30.72e6);
} else {
srslte_rf_set_master_clock_rate(&rf, 23.04e6);

@ -655,11 +655,19 @@ int srslte_uci_encode_ack(srslte_pusch_cfg_t *cfg, uint8_t acks[2], uint32_t nof
uint32_t nof_encoded_bits = encode_ri_ack(acks, nof_acks, q_encoded_bits, cfg->grant.Qm);
for (uint32_t i=0;i<Qprime;i++) {
uci_ulsch_interleave_ack_gen(i, cfg->grant.Qm, H_prime_total, cfg->nbits.nof_symb, cfg->cp, &ack_bits[cfg->grant.Qm*i]);
uci_ulsch_interleave_put(&q_encoded_bits[(i*cfg->grant.Qm)%nof_encoded_bits], cfg->grant.Qm, &ack_bits[cfg->grant.Qm*i]);
if (nof_encoded_bits > 0) {
for (uint32_t i = 0; i < Qprime; i++) {
uci_ulsch_interleave_ack_gen(i,
cfg->grant.Qm,
H_prime_total,
cfg->nbits.nof_symb,
cfg->cp,
&ack_bits[cfg->grant.Qm * i]);
uci_ulsch_interleave_put(&q_encoded_bits[(i * cfg->grant.Qm) % nof_encoded_bits],
cfg->grant.Qm,
&ack_bits[cfg->grant.Qm * i]);
}
}
return (int) Qprime;
}
@ -706,6 +714,7 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t *cfg,
uint32_t nof_encoded_bits = encode_ri_ack(data, data_len, q_encoded_bits, cfg->grant.Qm);
if (nof_encoded_bits > 0) {
for (uint32_t i = 0; i < Qprime; i++) {
if (ack_ri) {
uci_ulsch_interleave_ri_gen(i,
@ -726,6 +735,7 @@ int srslte_uci_encode_ack_ri(srslte_pusch_cfg_t *cfg,
cfg->grant.Qm,
&bits[cfg->grant.Qm * i]);
}
}
return (int) Qprime;
}

@ -59,7 +59,7 @@ void usage(char *prog) {
printf("Usage: %s [nlestodv] -i cell_id -f input_file_name\n", prog);
printf("\t-n nof_frames [Default %d]\n", nof_frames);
printf("\t-l N_id_2 to sync [Default use cell_id]\n");
printf("\t-e Extended CP [Default Normal]\n", fft_size);
printf("\t-e Extended CP [Default Normal]\n");
printf("\t-s symbol_sz [Default %d]\n", fft_size);
printf("\t-t threshold [Default %.2f]\n", threshold);
printf("\t-o file read offset [Default %d]\n", file_offset);
@ -266,7 +266,7 @@ int main(int argc, char **argv) {
}
} else {
INFO("No space for CFO computation. Frame starts at \n",peak_idx);
INFO("No space for CFO computation. Frame starts at \n");
}
if(srslte_sss_subframe(m0,m1) == 0)

@ -61,7 +61,7 @@ void usage(char *prog) {
printf("\t-g RF Gain [Default %.2f dB]\n", rf_gain);
printf("\t-n nof_frames [Default %d]\n", nof_frames);
printf("\t-l N_id_2 to sync [Default use cell_id]\n");
printf("\t-e Extended CP [Default Normal]\n", fft_size);
printf("\t-e Extended CP [Default Normal]\n");
printf("\t-s symbol_sz [Default %d]\n", fft_size);
printf("\t-t threshold [Default %.2f]\n", threshold);
#ifndef DISABLE_GRAPHICS
@ -291,7 +291,7 @@ int main(int argc, char **argv) {
}
} else {
INFO("No space for CFO computation. Frame starts at \n",peak_idx);
INFO("No space for CFO computation. Frame starts at \n");
}
if(srslte_sss_subframe(m0,m1) == 0)

@ -896,7 +896,7 @@ static int find_dl_dci_type_crnti(srslte_ue_dl_t *q, uint32_t tm, uint32_t cfi,
dci_blind_search_t *current_ss = &search_space;
if (cfi < 1 || cfi > 3) {
ERROR("CFI must be 1 ≤ cfi ≤ 3", cfi);
ERROR("CFI must be 1 ≤ cfi ≤ 3 (cfi=%d)", cfi);
return SRSLTE_ERROR;
}

@ -30,7 +30,14 @@
namespace srslte {
pdcp::pdcp()
{}
{
rlc = NULL;
rrc = NULL;
gw = NULL;
pdcp_log = NULL;
lcid = 0;
direction = 0;
}
void pdcp::init(srsue::rlc_interface_pdcp *rlc_, srsue::rrc_interface_pdcp *rrc_, srsue::gw_interface_pdcp *gw_, log *pdcp_log_, uint32_t lcid_, uint8_t direction_)
{

@ -35,6 +35,17 @@ pdcp_entity::pdcp_entity()
,tx_count(0)
{
pool = byte_buffer_pool::get_instance();
log = NULL;
rlc = NULL;
rrc = NULL;
gw = NULL;
lcid = 0;
sn_len_bytes = 0;
do_integrity = false;
do_encryption = false;
rx_count = 0;
cipher_algo = CIPHERING_ALGORITHM_ID_EEA0;
integ_algo = INTEGRITY_ALGORITHM_ID_EIA0;
}
void pdcp_entity::init(srsue::rlc_interface_pdcp *rlc_,

@ -35,6 +35,15 @@ namespace srslte {
rlc::rlc()
{
pool = byte_buffer_pool::get_instance();
rlc_log = NULL;
pdcp = NULL;
rrc = NULL;
mac_timers = NULL;
ue = NULL;
default_lcid = 0;
bzero(metrics_time, sizeof(metrics_time));
bzero(ul_tput_bytes, sizeof(ul_tput_bytes));
bzero(dl_tput_bytes, sizeof(dl_tput_bytes));
}
void rlc::init(srsue::pdcp_interface_rlc *pdcp_,
@ -233,7 +242,7 @@ void rlc::add_bearer(uint32_t lcid)
void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg)
{
if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) {
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
rlc_log->error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_RADIO_BEARERS, lcid);
return;
}
@ -271,10 +280,9 @@ void rlc::add_bearer(uint32_t lcid, srslte_rlc_config_t cnfg)
*******************************************************************************/
bool rlc::valid_lcid(uint32_t lcid)
{
if(lcid < 0 || lcid >= SRSLTE_N_RADIO_BEARERS) {
if(lcid >= SRSLTE_N_RADIO_BEARERS) {
return false;
}
if(!rlc_array[lcid].active()) {
} else if(!rlc_array[lcid].active()) {
return false;
}
return true;

@ -38,6 +38,12 @@ namespace srslte {
rlc_am::rlc_am() : tx_sdu_queue(16)
{
log = NULL;
pdcp = NULL;
rrc = NULL;
lcid = 0;
bzero(&cfg, sizeof(srslte_rlc_am_config_t));
tx_sdu = NULL;
rx_sdu = NULL;
pool = byte_buffer_pool::get_instance();
@ -768,7 +774,7 @@ int rlc_am::build_data_pdu(uint8_t *payload, uint32_t nof_bytes)
return (ptr-payload) + pdu->N_bytes;
}
void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header)
void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header)
{
std::map<uint32_t, rlc_amd_rx_pdu_t>::iterator it;
@ -806,7 +812,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h
memcpy(pdu.buf->msg, payload, nof_bytes);
pdu.buf->N_bytes = nof_bytes;
pdu.header = header;
memcpy(&pdu.header, &header, sizeof(rlc_amd_pdu_header_t));
rx_window[header.sn] = pdu;
@ -865,7 +871,7 @@ void rlc_am::handle_data_pdu(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_h
debug_state();
}
void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t header)
void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_amd_pdu_header_t &header)
{
std::map<uint32_t, rlc_amd_rx_pdu_segments_t>::iterator it;
@ -891,7 +897,7 @@ void rlc_am::handle_data_pdu_segment(uint8_t *payload, uint32_t nof_bytes, rlc_a
}
memcpy(segment.buf->msg, payload, nof_bytes);
segment.buf->N_bytes = nof_bytes;
segment.header = header;
memcpy(&segment.header, &header, sizeof(rlc_amd_pdu_header_t));
// Check if we already have a segment from the same PDU
it = rx_segments.find(header.sn);

@ -31,6 +31,10 @@ namespace srslte {
rlc_tm::rlc_tm() : ul_queue(16)
{
log = NULL;
pdcp = NULL;
rrc = NULL;
lcid = 0;
pool = byte_buffer_pool::get_instance();
}

@ -33,6 +33,14 @@ namespace srslte {
rlc_um::rlc_um() : tx_sdu_queue(16)
{
log = NULL;
pdcp = NULL;
rrc = NULL;
reordering_timer = NULL;
lcid = 0;
reordering_timer_id = 0;
bzero(&cfg, sizeof(srslte_rlc_um_config_t));
tx_sdu = NULL;
rx_sdu = NULL;
pool = byte_buffer_pool::get_instance();

@ -67,7 +67,7 @@ void write(std::string filename) {
bool read(std::string filename) {
bool pass = true;
bool written[NTHREADS][NMSGS];
int thread, msg;
int thread = 0, msg = 0;
int r;
for(int i=0;i<NTHREADS;i++) {
@ -78,7 +78,12 @@ bool read(std::string filename) {
FILE *f = fopen(filename.c_str(), "r");
if(f!=NULL) {
while(fscanf(f, "Thread %d: %d\n", &thread, &msg)) {
if (thread < NTHREADS && msg < NMSGS) {
written[thread][msg] = true;
} else {
perror("Wrong thread and/or msg");
return false;
}
}
fclose(f);
}
@ -95,7 +100,11 @@ int main(int argc, char **argv) {
std::string f("log.txt");
write(f);
result = read(f);
remove(f.c_str());
if (remove(f.c_str())) {
perror("Removing file");
}
if(result) {
printf("Passed\n");
exit(0);

@ -39,6 +39,7 @@ public:
finished = false;
pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cvar, NULL);
bzero(&start_time, sizeof(start_time));
}
void timeout_expired(uint32_t timeout_id)

@ -54,7 +54,10 @@ class rlc_am_tester
,public rrc_interface_rlc
{
public:
rlc_am_tester(){n_sdus = 0;}
rlc_am_tester(){
bzero(sdus, sizeof(sdus));
n_sdus = 0;
}
// PDCP interface
void write_pdu(uint32_t lcid, byte_buffer_t *sdu)

@ -57,7 +57,10 @@ class rlc_um_tester
,public rrc_interface_rlc
{
public:
rlc_um_tester(){n_sdus = 0;}
rlc_um_tester(){
bzero(sdus, sizeof(sdus));
n_sdus = 0;
}
// PDCP interface
void write_pdu(uint32_t lcid, byte_buffer_t *sdu)

@ -43,7 +43,14 @@ class ue : public srslte::read_pdu_interface,
{
public:
ue() : mac_msg_dl(20), mac_msg_ul(20), pdus(128) {
ue() : mac_msg_dl(20), mac_msg_ul(20), conres_id_available(false),
dl_ri_counter(0),
dl_pmi_counter(0),
conres_id(0),
last_tti(0),
pdus(128) {
rrc = NULL;
sched = NULL;
rlc = NULL;
log_h = NULL;
rnti = 0;
@ -55,6 +62,14 @@ public:
for (int i=0;i<NOF_HARQ_PROCESSES;i++) {
pending_buffers[i] = NULL;
}
bzero(&metrics, sizeof(mac_metrics_t));
bzero(&mutex, sizeof(pthread_mutex_t));
bzero(softbuffer_tx, sizeof(softbuffer_tx));
bzero(softbuffer_rx, sizeof(softbuffer_rx));
for (int i = 0; i < SRSLTE_MAX_TB; ++i) {
bzero(tx_payload_buffer, sizeof(uint8_t) * payload_buffer_len);
}
pthread_mutex_init(&mutex, NULL);
}

@ -57,6 +57,16 @@ public:
nof_mutex = 0;
max_mutex = max_mutex_;
params.max_prach_offset_us = 20;
radio = NULL;
mac = NULL;
is_first_tx = false;
is_first_of_burst = false;
pdsch_p_b = 0;
nof_workers = 0;
bzero(&pusch_cfg, sizeof(pusch_cfg));
bzero(&hopping_cfg, sizeof(hopping_cfg));
bzero(&pucch_cfg, sizeof(pucch_cfg));
bzero(&ul_grants, sizeof(ul_grants));
}
bool init(srslte_cell_t *cell, srslte::radio *radio_handler, mac_interface_phy *mac);

@ -103,7 +103,11 @@ private:
class ue {
public:
ue() : I_sr(0), I_sr_en(false), cqi_en(false), pucch_cqi_ack(false), pmi_idx(0), has_grant_tti(0),
dedicated_ack(false) {bzero(&metrics, sizeof(phy_metrics_t));}
dedicated_ack(false), ri_idx(0), ri_en(false), rnti(0) {
bzero(&dedicated, sizeof(LIBLTE_RRC_PHYSICAL_CONFIG_DEDICATED_STRUCT));
bzero(&phich_info, sizeof(srslte_enb_ul_phich_info_t));
bzero(&metrics, sizeof(phy_metrics_t));
}
uint32_t I_sr;
uint32_t pmi_idx;
uint32_t ri_idx;

@ -36,7 +36,20 @@ namespace srsenb {
class prach_worker : thread
{
public:
prach_worker() : initiated(false),max_prach_offset_us(0) {}
prach_worker() : initiated(false), prach_nof_det(0), max_prach_offset_us(0), pending_tti(0), processed_tti(0),
running(false), nof_sf(0), sf_cnt(0) {
log_h = NULL;
mac = NULL;
signal_buffer_rx = NULL;
bzero(&prach, sizeof(srslte_prach_t));
bzero(&prach_indices, sizeof(prach_indices));
bzero(&prach_offsets, sizeof(prach_offsets));
bzero(&prach_p2avg, sizeof(prach_p2avg));
bzero(&cell, sizeof(cell));
bzero(&prach_cfg, sizeof(prach_cfg));
bzero(&mutex, sizeof(mutex));
bzero(&cvar, sizeof(cvar));
}
int init(srslte_cell_t *cell, srslte_prach_cfg_t *prach_cfg, mac_interface_phy *mac, srslte::log *log_h, int priority);
int new_tti(uint32_t tti, cf_t *buffer);

@ -104,7 +104,27 @@ class rrc : public rrc_interface_pdcp,
{
public:
rrc() : act_monitor(this), cnotifier(NULL) {}
rrc() : act_monitor(this), cnotifier(NULL), running(false), nof_si_messages(0) {
users.clear();
pending_paging.clear();
pool = NULL;
phy = NULL;
mac = NULL;
rlc = NULL;
pdcp = NULL;
gtpu = NULL;
s1ap = NULL;
rrc_log = NULL;
bzero(&sr_sched, sizeof(sr_sched));
bzero(&cqi_sched, sizeof(cqi_sched));
bzero(&cfg, sizeof(cfg));
bzero(&sib2, sizeof(sib2));
bzero(&user_mutex, sizeof(user_mutex));
bzero(&paging_mutex, sizeof(paging_mutex));
}
void init(rrc_cfg_t *cfg,
phy_interface_rrc *phy,

@ -54,11 +54,14 @@ void enb::cleanup(void)
}
}
enb::enb()
:started(false)
{
enb::enb() : started(false) {
srslte_dft_load();
pool = srslte::byte_buffer_pool::get_instance();
logger = NULL;
args = NULL;
bzero(&rf_metrics, sizeof(rf_metrics));
}
enb::~enb()

@ -55,8 +55,8 @@ int enb::parse_cell_cfg(all_args_t *args, srslte_cell_t *cell) {
);
parser::parse_section(args->enb_files.rr_config, &phy_cnfg);
cell->phich_length = (srslte_phich_length_t) phichcfg.dur;
cell->phich_resources = (srslte_phich_resources_t) phichcfg.res;
cell->phich_length = (srslte_phich_length_t) (int) phichcfg.dur;
cell->phich_resources = (srslte_phich_resources_t) (int) phichcfg.res;
if (!srslte_cell_isvalid(cell)) {
fprintf(stderr, "Invalid cell parameters: nof_prb=%d, cell_id=%d\n", args->enb.n_prb, args->enb.s1ap.cell_id);
@ -845,7 +845,7 @@ int enb::parse_rr(all_args_t* args, rrc_cfg_t* rrc_cfg)
{
/* Transmission mode config section */
if (args->enb.transmission_mode < 0 || args->enb.transmission_mode > 4) {
if (args->enb.transmission_mode < 1 || args->enb.transmission_mode > 4) {
ERROR("Invalid transmission mode (%d). Only indexes 1-4 are implemented.\n", args->enb.transmission_mode);
return SRSLTE_ERROR;
} else if (args->enb.transmission_mode == 1 && args->enb.nof_ports > 1) {

Loading…
Cancel
Save