all: fix uninitialized variables detected by coverity

master
Andre Puschmann 3 years ago
parent 3714548391
commit 70eaec21e2

@ -699,7 +699,6 @@ public:
class dnn_t class dnn_t
{ {
public: public:
uint32_t length;
std::vector<uint8_t> dnn_value; std::vector<uint8_t> dnn_value;
SRSASN_CODE pack(asn1::bit_ref& bref); SRSASN_CODE pack(asn1::bit_ref& bref);

@ -398,7 +398,7 @@ inline uint16_t enum_to_number(const pmch_info_t::mch_sched_period_t& mch_period
struct mcch_msg_t { struct mcch_msg_t {
uint32_t nof_common_sf_alloc = 0; uint32_t nof_common_sf_alloc = 0;
mbsfn_sf_cfg_t common_sf_alloc[8]; mbsfn_sf_cfg_t common_sf_alloc[8] = {};
enum class common_sf_alloc_period_t { rf4, rf8, rf16, rf32, rf64, rf128, rf256, nulltype } common_sf_alloc_period; enum class common_sf_alloc_period_t { rf4, rf8, rf16, rf32, rf64, rf128, rf256, nulltype } common_sf_alloc_period;
uint32_t nof_pmch_info; uint32_t nof_pmch_info;
pmch_info_t pmch_info_list[15]; pmch_info_t pmch_info_list[15];

@ -132,7 +132,7 @@ private:
class sdu_buffer class sdu_buffer
{ {
static const uint8_t mac_ce_payload_len = 8 + 1; // Long BSR has max. 9 octets (see sizeof_ce() too) static const uint8_t mac_ce_payload_len = 8 + 1; // Long BSR has max. 9 octets (see sizeof_ce() too)
std::array<uint8_t, mac_ce_payload_len> ce_write_buffer; // Buffer for CE payload std::array<uint8_t, mac_ce_payload_len> ce_write_buffer = {}; // Buffer for CE payload
uint8_t* sdu = nullptr; uint8_t* sdu = nullptr;
public: public:

@ -28,7 +28,7 @@ struct rlc_sn_info_t {
struct rlc_amd_rx_pdu { struct rlc_amd_rx_pdu {
rlc_amd_pdu_header_t header; rlc_amd_pdu_header_t header;
unique_byte_buffer_t buf; unique_byte_buffer_t buf;
uint32_t rlc_sn; uint32_t rlc_sn = 0;
rlc_amd_rx_pdu() = default; rlc_amd_rx_pdu() = default;
explicit rlc_amd_rx_pdu(uint32_t rlc_sn_) : rlc_sn(rlc_sn_) {} explicit rlc_amd_rx_pdu(uint32_t rlc_sn_) : rlc_sn(rlc_sn_) {}

@ -29,7 +29,7 @@ struct sys_metrics_t {
float process_cpu_usage = 0.f; float process_cpu_usage = 0.f;
float system_mem = 0.f; float system_mem = 0.f;
uint32_t cpu_count = 0; uint32_t cpu_count = 0;
std::array<float, metrics_max_supported_cpu> cpu_load; std::array<float, metrics_max_supported_cpu> cpu_load = {};
}; };
} // namespace srsran } // namespace srsran

@ -1147,7 +1147,7 @@ bool make_phy_pusch_scaling(const uci_on_pusch_s& uci_on_pusch, float* in_scalin
bool make_phy_zp_csi_rs_resource(const asn1::rrc_nr::zp_csi_rs_res_s& zp_csi_rs_res, bool make_phy_zp_csi_rs_resource(const asn1::rrc_nr::zp_csi_rs_res_s& zp_csi_rs_res,
srsran_csi_rs_zp_resource_t* out_zp_csi_rs_resource) srsran_csi_rs_zp_resource_t* out_zp_csi_rs_resource)
{ {
srsran_csi_rs_zp_resource_t zp_csi_rs_resource; srsran_csi_rs_zp_resource_t zp_csi_rs_resource = {};
zp_csi_rs_resource.id = zp_csi_rs_res.zp_csi_rs_res_id; zp_csi_rs_resource.id = zp_csi_rs_res.zp_csi_rs_res_id;
switch (zp_csi_rs_res.res_map.freq_domain_alloc.type()) { switch (zp_csi_rs_res.res_map.freq_domain_alloc.type()) {
case csi_rs_res_map_s::freq_domain_alloc_c_::types_opts::options::row1: case csi_rs_res_map_s::freq_domain_alloc_c_::types_opts::options::row1:
@ -1312,7 +1312,7 @@ bool make_phy_zp_csi_rs_resource(const asn1::rrc_nr::zp_csi_rs_res_s& zp_csi_rs_
bool make_phy_nzp_csi_rs_resource(const asn1::rrc_nr::nzp_csi_rs_res_s& asn1_nzp_csi_rs_res, bool make_phy_nzp_csi_rs_resource(const asn1::rrc_nr::nzp_csi_rs_res_s& asn1_nzp_csi_rs_res,
srsran_csi_rs_nzp_resource_t* out_csi_rs_nzp_resource) srsran_csi_rs_nzp_resource_t* out_csi_rs_nzp_resource)
{ {
srsran_csi_rs_nzp_resource_t csi_rs_nzp_resource; srsran_csi_rs_nzp_resource_t csi_rs_nzp_resource = {};
csi_rs_nzp_resource.id = asn1_nzp_csi_rs_res.nzp_csi_rs_res_id; csi_rs_nzp_resource.id = asn1_nzp_csi_rs_res.nzp_csi_rs_res_id;
switch (asn1_nzp_csi_rs_res.res_map.freq_domain_alloc.type()) { switch (asn1_nzp_csi_rs_res.res_map.freq_domain_alloc.type()) {
case csi_rs_res_map_s::freq_domain_alloc_c_::types_opts::options::row1: case csi_rs_res_map_s::freq_domain_alloc_c_::types_opts::options::row1:

@ -325,7 +325,7 @@ mac_sch_subpdu_nr::lbsr_t mac_sch_subpdu_nr::get_lbsr() const
mac_sch_subpdu_nr::ue_con_res_id_t mac_sch_subpdu_nr::get_ue_con_res_id_ce() mac_sch_subpdu_nr::ue_con_res_id_t mac_sch_subpdu_nr::get_ue_con_res_id_ce()
{ {
mac_sch_subpdu_nr::ue_con_res_id_t id; mac_sch_subpdu_nr::ue_con_res_id_t id = {};
if (!parent->is_ulsch() && lcid == CON_RES_ID) { if (!parent->is_ulsch() && lcid == CON_RES_ID) {
const uint8_t* ptr = sdu.ptr(); const uint8_t* ptr = sdu.ptr();
memcpy(id.data(), ptr, id.size()); memcpy(id.data(), ptr, id.size());

@ -428,7 +428,7 @@ int srsran_dmrs_pdcch_get_measure(const srsran_dmrs_pdcch_estimator_t* q,
// For each CORESET symbol // For each CORESET symbol
for (uint32_t l = 0; l < q->coreset.duration; l++) { for (uint32_t l = 0; l < q->coreset.duration; l++) {
// Temporal least square estimates // Temporal least square estimates
cf_t tmp[DMRS_PDCCH_MAX_NOF_PILOTS_CANDIDATE]; cf_t tmp[DMRS_PDCCH_MAX_NOF_PILOTS_CANDIDATE] = {};
uint32_t nof_pilots = 0; uint32_t nof_pilots = 0;
// For each RB in the CORESET // For each RB in the CORESET

@ -26,6 +26,7 @@ static int test_row1()
} }
m.nof_ports = 1; m.nof_ports = 1;
m.first_symbol_idx = 0; m.first_symbol_idx = 0;
m.first_symbol_idx2 = 0;
m.cdm = srsran_csi_rs_cdm_nocdm; m.cdm = srsran_csi_rs_cdm_nocdm;
m.density = srsran_csi_rs_resource_mapping_density_three; m.density = srsran_csi_rs_resource_mapping_density_three;
m.freq_band.start_rb = carrier.start; m.freq_band.start_rb = carrier.start;
@ -69,6 +70,7 @@ static int test_row2()
} }
m.nof_ports = 1; m.nof_ports = 1;
m.first_symbol_idx = 0; m.first_symbol_idx = 0;
m.first_symbol_idx2 = 0;
m.cdm = srsran_csi_rs_cdm_nocdm; m.cdm = srsran_csi_rs_cdm_nocdm;
m.density = density; m.density = density;
m.freq_band.start_rb = carrier.start; m.freq_band.start_rb = carrier.start;

@ -134,7 +134,8 @@ int main(int argc, char** argv)
srsran_chest_dl_res_t chest_dl_res; srsran_chest_dl_res_t chest_dl_res;
srsran_pmch_t pmch; srsran_pmch_t pmch;
srsran_pmch_cfg_t pmch_cfg; srsran_pmch_cfg_t pmch_cfg;
srsran_ofdm_t ifft_mbsfn[SRSRAN_MAX_PORTS], fft_mbsfn[SRSRAN_MAX_PORTS]; srsran_ofdm_t ifft_mbsfn[SRSRAN_MAX_PORTS] = {};
srsran_ofdm_t fft_mbsfn[SRSRAN_MAX_PORTS] = {};
parse_args(argc, argv); parse_args(argc, argv);
/* Initialise to zeros */ /* Initialise to zeros */

@ -173,17 +173,17 @@ void parse_args(int argc, char** argv)
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
srsran_random_t random_h = srsran_random_init(0); srsran_random_t random_h = srsran_random_init(0);
srsran_chest_ul_res_t chest_res; srsran_chest_ul_res_t chest_res = {};
srsran_pusch_t pusch_tx; srsran_pusch_t pusch_tx = {};
srsran_pusch_t pusch_rx; srsran_pusch_t pusch_rx = {};
uint8_t* data = NULL; uint8_t* data = NULL;
uint8_t* data_rx = NULL; uint8_t* data_rx = NULL;
cf_t* sf_symbols = NULL; cf_t* sf_symbols = NULL;
int ret = -1; int ret = -1;
struct timeval t[3]; struct timeval t[3];
srsran_pusch_cfg_t cfg; srsran_pusch_cfg_t cfg = {};
srsran_softbuffer_tx_t softbuffer_tx; srsran_softbuffer_tx_t softbuffer_tx = {};
srsran_softbuffer_rx_t softbuffer_rx; srsran_softbuffer_rx_t softbuffer_rx = {};
srsran_crc_t crc_tb; srsran_crc_t crc_tb;
ZERO_OBJECT(uci_data_tx); ZERO_OBJECT(uci_data_tx);

@ -391,7 +391,7 @@ void srsran_nbiot_ue_dl_decode_sib1(srsran_nbiot_ue_dl_t* q, uint32_t current_sf
// activate SIB1 grant and configure NPDSCH // activate SIB1 grant and configure NPDSCH
INFO( INFO(
"%d.x: Activated SIB1 decoding in sfn=%d\n", current_sfn, srsran_nbiot_ue_dl_get_next_sib1_start(q, current_sfn)); "%d.x: Activated SIB1 decoding in sfn=%d\n", current_sfn, srsran_nbiot_ue_dl_get_next_sib1_start(q, current_sfn));
srsran_ra_nbiot_dl_grant_t grant; srsran_ra_nbiot_dl_grant_t grant = {};
srsran_nbiot_ue_dl_get_sib1_grant(q, current_sfn, &grant); srsran_nbiot_ue_dl_get_sib1_grant(q, current_sfn, &grant);
srsran_nbiot_ue_dl_set_grant(q, &grant); srsran_nbiot_ue_dl_set_grant(q, &grant);
} }
@ -410,7 +410,7 @@ void srsran_nbiot_ue_dl_decode_sib(srsran_nbiot_ue_dl_t* q,
if (type == SRSRAN_NBIOT_SI_TYPE_SIB2) { if (type == SRSRAN_NBIOT_SI_TYPE_SIB2) {
assert(params.n == 1); assert(params.n == 1);
// calculate SIB2 params // calculate SIB2 params
srsran_ra_nbiot_dl_grant_t grant; srsran_ra_nbiot_dl_grant_t grant = {};
srsran_nbiot_ue_dl_get_sib_grant(q, hfn, sfn, params, &grant); srsran_nbiot_ue_dl_get_sib_grant(q, hfn, sfn, params, &grant);
srsran_nbiot_ue_dl_set_grant(q, &grant); srsran_nbiot_ue_dl_set_grant(q, &grant);
INFO("%d.x: Activated SIB2 reception in hfn=%d, sfn=%d", INFO("%d.x: Activated SIB2 reception in hfn=%d, sfn=%d",

@ -115,7 +115,7 @@ bool rlc_um_lte::rlc_um_lte_tx::configure(const rlc_config_t& cnfg_, std::string
uint32_t rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes) uint32_t rlc_um_lte::rlc_um_lte_tx::build_data_pdu(unique_byte_buffer_t pdu, uint8_t* payload, uint32_t nof_bytes)
{ {
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
rlc_umd_pdu_header_t header; rlc_umd_pdu_header_t header = {};
header.fi = RLC_FI_FIELD_START_AND_END_ALIGNED; header.fi = RLC_FI_FIELD_START_AND_END_ALIGNED;
header.sn = vt_us; header.sn = vt_us;
header.N_li = 0; header.N_li = 0;

@ -395,7 +395,7 @@ int test_seq_of()
cbit_ref borig2(&buf[0], sizeof(buf)); cbit_ref borig2(&buf[0], sizeof(buf));
uint32_t fixed_list_size = 33; uint32_t fixed_list_size = 33;
std::array<uint32_t, 33> fixed_list; std::array<uint32_t, 33> fixed_list = {};
for (uint32_t i = 0; i < fixed_list_size; ++i) { for (uint32_t i = 0; i < fixed_list_size; ++i) {
fixed_list[i] = i; fixed_list[i] = i;
} }

@ -128,7 +128,7 @@ void sched_tester::before_sched()
for (auto& it : ue_db) { for (auto& it : ue_db) {
uint16_t rnti = it.first; uint16_t rnti = it.first;
srsenb::sched_ue* user = it.second.get(); srsenb::sched_ue* user = it.second.get();
tester_user_results d; tester_user_results d = {};
tti_data.ue_data.insert(std::make_pair(rnti, d)); tti_data.ue_data.insert(std::make_pair(rnti, d));
// NOTE: ACK might have just cleared the harq for tti_info.tti_params.tti_tx_ul // NOTE: ACK might have just cleared the harq for tti_info.tti_params.tti_tx_ul

@ -44,7 +44,7 @@ int test_erab_setup(srsran::log_sink_spy& spy, bool qci_exists)
rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu); rrc.init(cfg, &phy, &mac, &rlc, &pdcp, &s1ap, &gtpu);
uint16_t rnti = 0x46; uint16_t rnti = 0x46;
sched_interface::ue_cfg_t ue_cfg; sched_interface::ue_cfg_t ue_cfg = {};
ue_cfg.supported_cc_list.resize(1); ue_cfg.supported_cc_list.resize(1);
ue_cfg.supported_cc_list[0].active = true; ue_cfg.supported_cc_list[0].active = true;
ue_cfg.supported_cc_list[0].enb_cc_idx = 0; ue_cfg.supported_cc_list[0].enb_cc_idx = 0;

@ -384,7 +384,7 @@ int main(int argc, char* argv[])
cout << endl << "--- Software Radio Systems EPC ---" << endl << endl; cout << endl << "--- Software Radio Systems EPC ---" << endl << endl;
srsran_debug_handle_crash(argc, argv); srsran_debug_handle_crash(argc, argv);
all_args_t args; all_args_t args = {};
parse_args(&args, argc, argv); parse_args(&args, argc, argv);
// Setup logging. // Setup logging.

@ -49,7 +49,7 @@ void test_sib_generation()
enb_bearer_manager bearer_mapper; enb_bearer_manager bearer_mapper;
// set cfg // set cfg
rrc_nr_cfg_t rrc_cfg_nr; rrc_nr_cfg_t rrc_cfg_nr = {};
rrc_cfg_nr.cell_list.emplace_back(); rrc_cfg_nr.cell_list.emplace_back();
generate_default_nr_cell(rrc_cfg_nr.cell_list[0]); generate_default_nr_cell(rrc_cfg_nr.cell_list[0]);
rrc_cfg_nr.cell_list[0].phy_cell.carrier.pci = 500; rrc_cfg_nr.cell_list[0].phy_cell.carrier.pci = 500;
@ -153,7 +153,7 @@ void test_rrc_sa_connection()
rlc_cfg.um_bi_dir().dl_um_rlc.t_reassembly = t_reassembly_e::ms50; rlc_cfg.um_bi_dir().dl_um_rlc.t_reassembly = t_reassembly_e::ms50;
// set cfg // set cfg
rrc_nr_cfg_t rrc_cfg_nr; rrc_nr_cfg_t rrc_cfg_nr = {};
rrc_cfg_nr.cell_list.emplace_back(); rrc_cfg_nr.cell_list.emplace_back();
generate_default_nr_cell(rrc_cfg_nr.cell_list[0]); generate_default_nr_cell(rrc_cfg_nr.cell_list[0]);
rrc_cfg_nr.cell_list[0].phy_cell.carrier.pci = 500; rrc_cfg_nr.cell_list[0].phy_cell.carrier.pci = 500;

@ -33,11 +33,11 @@ struct info_metrics_t {
struct sync_metrics_t { struct sync_metrics_t {
typedef std::array<sync_metrics_t, SRSRAN_MAX_CARRIERS> array_t; typedef std::array<sync_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
float ta_us; float ta_us = 0.0;
float distance_km; float distance_km = 0.0;
float speed_kmph; float speed_kmph = 0.0;
float cfo; float cfo = 0.0;
float sfo; float sfo = 0.0;
void set(const sync_metrics_t& other) void set(const sync_metrics_t& other)
{ {
@ -66,14 +66,14 @@ private:
struct ch_metrics_t { struct ch_metrics_t {
typedef std::array<ch_metrics_t, SRSRAN_MAX_CARRIERS> array_t; typedef std::array<ch_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
float n; float n = 0.0;
float sinr; float sinr = 0.0;
float rsrp; float rsrp = 0.0;
float rsrq; float rsrq = 0.0;
float rssi; float rssi = 0.0;
float ri; float ri = 0.0;
float pathloss; float pathloss = 0.0;
float sync_err; float sync_err = 0.0;
void set(const ch_metrics_t& other) void set(const ch_metrics_t& other)
{ {
@ -111,9 +111,9 @@ private:
struct dl_metrics_t { struct dl_metrics_t {
typedef std::array<dl_metrics_t, SRSRAN_MAX_CARRIERS> array_t; typedef std::array<dl_metrics_t, SRSRAN_MAX_CARRIERS> array_t;
float fec_iters; float fec_iters = 0.0;
float mcs; float mcs = 0.0;
float evm; float evm = 0.0;
void set(const dl_metrics_t& other) void set(const dl_metrics_t& other)
{ {

@ -57,6 +57,7 @@ int test_add_neighbours()
TESTASSERT(list.get_neighbour_cell_handle(0, 0) == nullptr); TESTASSERT(list.get_neighbour_cell_handle(0, 0) == nullptr);
phy_meas_t pmeas; phy_meas_t pmeas;
pmeas.rat = srsran::srsran_rat_t::lte;
pmeas.cfo_hz = 4; pmeas.cfo_hz = 4;
pmeas.rsrp = -20; pmeas.rsrp = -20;
pmeas.pci = 1; pmeas.pci = 1;

@ -157,7 +157,7 @@ int rrc_nr_cap_request_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
rrc_nr_args.supported_bands_eutra.push_back(7); rrc_nr_args.supported_bands_eutra.push_back(7);
rrc_nr_args.supported_bands_nr.push_back(78); rrc_nr_args.supported_bands_nr.push_back(78);
@ -199,7 +199,7 @@ int rrc_nsa_reconfig_tdd_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
TESTASSERT(rrc_nr.init(&dummy_phy, TESTASSERT(rrc_nr.init(&dummy_phy,
&dummy_mac, &dummy_mac,
&dummy_rlc, &dummy_rlc,
@ -302,7 +302,7 @@ int rrc_nsa_reconfig_fdd_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
TESTASSERT(rrc_nr.init(&dummy_phy, TESTASSERT(rrc_nr.init(&dummy_phy,
&dummy_mac, &dummy_mac,
&dummy_rlc, &dummy_rlc,
@ -406,7 +406,7 @@ int rrc_nr_setup_request_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
rrc_nr_args.supported_bands_nr.push_back(78); rrc_nr_args.supported_bands_nr.push_back(78);
@ -450,7 +450,7 @@ int rrc_nr_sib1_decoding_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
TESTASSERT(rrc_nr.init(&dummy_phy, TESTASSERT(rrc_nr.init(&dummy_phy,
&dummy_mac, &dummy_mac,
&dummy_rlc, &dummy_rlc,
@ -499,7 +499,7 @@ int rrc_nr_setup_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
TESTASSERT(rrc_nr.init(&dummy_phy, TESTASSERT(rrc_nr.init(&dummy_phy,
&dummy_mac, &dummy_mac,
&dummy_rlc, &dummy_rlc,
@ -554,7 +554,7 @@ int rrc_nr_reconfig_test()
dummy_eutra dummy_eutra; dummy_eutra dummy_eutra;
dummy_sim dummy_sim; dummy_sim dummy_sim;
dummy_stack dummy_stack; dummy_stack dummy_stack;
rrc_nr_args_t rrc_nr_args; rrc_nr_args_t rrc_nr_args = {};
TESTASSERT(rrc_nr.init(&dummy_phy, TESTASSERT(rrc_nr.init(&dummy_phy,
&dummy_mac, &dummy_mac,
&dummy_rlc, &dummy_rlc,

@ -23,12 +23,7 @@ using namespace srsran;
namespace srsue { namespace srsue {
pcsc_usim::pcsc_usim(srslog::basic_logger& logger) : usim_base(logger), sc(logger) pcsc_usim::pcsc_usim(srslog::basic_logger& logger) : usim_base(logger), sc(logger) {}
{
bzero(ck, CK_LEN);
bzero(ik, IK_LEN);
bzero(auts, IK_LEN);
}
pcsc_usim::~pcsc_usim() pcsc_usim::~pcsc_usim()
{ {

Loading…
Cancel
Save