diff --git a/lib/include/srslte/common/pdu.h b/lib/include/srslte/common/pdu.h index 428ee1dca..9a9bdd7a3 100644 --- a/lib/include/srslte/common/pdu.h +++ b/lib/include/srslte/common/pdu.h @@ -209,11 +209,20 @@ private: class sch_subh : public subh { - -public: - - - sch_subh(subh_type type_ = SCH_SUBH_TYPE):type(type_){} +public: + sch_subh(subh_type type_ = SCH_SUBH_TYPE) { + lcid = 0; + nof_bytes = 0; + payload = NULL; + nof_mch_sched_ce = 0; + cur_mch_sched_ce = 0; + F_bit = false; + type = type_; + nof_mch_sched_ce = 0; + cur_mch_sched_ce = 0; + parent = NULL; + bzero(&w_payload_ce, sizeof(w_payload_ce)); + } virtual ~sch_subh(){} @@ -246,13 +255,10 @@ public: cetype ce_type(); uint32_t size_plus_header(); void set_payload_size(uint32_t size); - - bool read_subheader(uint8_t** ptr); void read_payload(uint8_t **ptr); - uint32_t get_sdu_lcid(); uint32_t get_payload_size(); uint32_t get_header_size(bool is_last); @@ -267,12 +273,9 @@ public: bool get_next_mch_sched_info(uint8_t *lcid, uint16_t *mtch_stop); // Writing functions - - void write_subheader(uint8_t** ptr, bool is_last); void write_payload(uint8_t **ptr); - int set_sdu(uint32_t lcid, uint32_t nof_bytes, uint8_t *payload); int set_sdu(uint32_t lcid, uint32_t requested_bytes, read_pdu_interface *sdu_itf); bool set_c_rnti(uint16_t crnti); @@ -291,7 +294,7 @@ public: protected: -static const int MAX_CE_PAYLOAD_LEN = 8; + static const int MAX_CE_PAYLOAD_LEN = 8; uint32_t lcid; int nof_bytes; uint8_t* payload; @@ -301,9 +304,6 @@ static const int MAX_CE_PAYLOAD_LEN = 8; bool F_bit; subh_type type; - - - private: uint32_t sizeof_ce(uint32_t lcid, bool is_ul); static uint8_t buff_size_table(uint32_t buffer_size); @@ -314,7 +314,6 @@ private: class sch_pdu : public pdu { public: - sch_pdu(uint32_t max_subh): pdu(max_subh) {} void parse_packet(uint8_t *ptr); @@ -336,6 +335,13 @@ public: class rar_subh : public subh { public: + rar_subh() { + bzero(&grant, sizeof(grant)); + ta = 0; + temp_rnti = 0; + preamble = 0; + parent = NULL; + } static const uint32_t RAR_GRANT_LEN = 20; @@ -386,25 +392,19 @@ private: class mch_subh : public sch_subh { - public: mch_subh():sch_subh(MCH_SUBH_TYPE){} - - - -// // Size of MAC CEs - const static int MAC_CE_CONTRES_LEN = 6; - + // Size of MAC CEs + const static int MAC_CE_CONTRES_LEN = 6; }; class mch_pdu : public sch_pdu { public: - mch_pdu(uint32_t max_subh) : sch_pdu(max_subh) {} - private: +private: /* Prepares the PDU for parsing or writing by setting the number of subheaders to 0 and the pdu length */ virtual void init_(uint8_t *buffer_tx_ptr, uint32_t pdu_len_bytes, bool is_ulsch) { diff --git a/lib/src/common/pdu.cc b/lib/src/common/pdu.cc index 05c23a389..d36b67f9f 100644 --- a/lib/src/common/pdu.cc +++ b/lib/src/common/pdu.cc @@ -615,7 +615,7 @@ int sch_subh::set_sdu(uint32_t lcid_, uint32_t requested_bytes, read_pdu_interfa // Save final number of written bytes nof_bytes = sdu_sz; - if(nof_bytes > requested_bytes) { + if(nof_bytes > (int32_t)requested_bytes) { return -1; } } diff --git a/lib/src/phy/ch_estimation/chest_dl.c b/lib/src/phy/ch_estimation/chest_dl.c index cb291b449..578bd177b 100644 --- a/lib/src/phy/ch_estimation/chest_dl.c +++ b/lib/src/phy/ch_estimation/chest_dl.c @@ -271,10 +271,9 @@ static float estimate_noise_pilots(srslte_chest_dl_t *q, uint32_t port_id, srslt float sum_power = 0.0f; uint32_t count = 0; uint32_t npilots = (ch_mode == SRSLTE_SF_MBSFN)?SRSLTE_REFSIGNAL_NUM_SF_MBSFN(q->cell.nof_prb, port_id):SRSLTE_REFSIGNAL_NUM_SF(q->cell.nof_prb, port_id); - uint32_t nsymbols = - (ch_mode == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_nof_symbols() : srslte_refsignal_cs_nof_symbols(port_id); + uint32_t nsymbols = (ch_mode == SRSLTE_SF_MBSFN) ? srslte_refsignal_mbsfn_nof_symbols() : srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = npilots / nsymbols; - uint32_t fidx = (ch_mode == SRSLTE_SF_MBSFN)?srslte_refsignal_mbsfn_fidx(1):srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); + uint32_t fidx = (ch_mode == SRSLTE_SF_MBSFN)?srslte_refsignal_mbsfn_fidx(1):srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); cf_t *input2d[nsymbols + 2]; cf_t *tmp_noise = q->tmp_noise; @@ -502,7 +501,6 @@ uint32_t srslte_chest_dl_interleave_pilots(srslte_chest_dl_t *q, cf_t *input, cf uint32_t nref = (ch_mode == SRSLTE_SF_MBSFN)?6*q->cell.nof_prb:2*q->cell.nof_prb; uint32_t fidx = (ch_mode == SRSLTE_SF_MBSFN)?srslte_refsignal_mbsfn_fidx(1):srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); - if (fidx < 3) { srslte_vec_interleave(input, &input[nref], tmp, nref); for (int l = 2; l < nsymbols - 1; l += 2) { @@ -524,7 +522,6 @@ uint32_t srslte_chest_dl_interleave_pilots(srslte_chest_dl_t *q, cf_t *input, cf static void average_pilots(srslte_chest_dl_t *q, cf_t *input, cf_t *output, uint32_t port_id, srslte_sf_t ch_mode) { uint32_t nsymbols = (ch_mode == SRSLTE_SF_MBSFN)?srslte_refsignal_mbsfn_nof_symbols(port_id):srslte_refsignal_cs_nof_symbols(port_id); uint32_t nref = (ch_mode == SRSLTE_SF_MBSFN)?6*q->cell.nof_prb:2*q->cell.nof_prb; - uint32_t fidx = (ch_mode == SRSLTE_SF_MBSFN)?srslte_refsignal_mbsfn_fidx(1):srslte_refsignal_cs_fidx(q->cell, 0, port_id, 0); // Average in the time domain if enabled if (q->average_subframe) { diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index 989498d83..b8dcf26e9 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -648,7 +648,6 @@ int mac::get_mch_sched(bool is_mcch, dl_sched_t *dl_sched_res) dl_sched_res->sched_grants[0].data[0] = ue_db[SRSLTE_MRNTI]->generate_mch_pdu(mch, mch.num_mtch_sched + 1, mcs.tbs/8); } else { - uint32_t current_lcid = 1; uint32_t mtch_index = 0; uint32_t mtch_stop = mch.mtch_sched[mch.num_mtch_sched -1].stop; @@ -661,7 +660,7 @@ int mac::get_mch_sched(bool is_mcch, dl_sched_t *dl_sched_res) } } if(mch.current_sf_allocation_num <= mtch_stop) { - int requested_bytes = (mcs_data.tbs/8 > mch.mtch_sched[mtch_index].lcid_buffer_size)?mch.mtch_sched[mtch_index].lcid_buffer_size:mcs_data.tbs/8; + int requested_bytes = (mcs_data.tbs/8 > (int32_t)mch.mtch_sched[mtch_index].lcid_buffer_size)?mch.mtch_sched[mtch_index].lcid_buffer_size:mcs_data.tbs/8; int bytes_received = ue_db[SRSLTE_MRNTI]->read_pdu(current_lcid, mtch_payload_buffer, requested_bytes); mch.pdu[0].lcid = current_lcid; mch.pdu[0].nbytes = bytes_received; diff --git a/srsenb/src/mac/ue.cc b/srsenb/src/mac/ue.cc index 7335e0b12..697bc8b8d 100644 --- a/srsenb/src/mac/ue.cc +++ b/srsenb/src/mac/ue.cc @@ -200,7 +200,7 @@ void ue::process_pdu(uint8_t* pdu, uint32_t nof_bytes, srslte::pdu_queue::channe // Save contention resolution if lcid == 0 if (mac_msg_ul.get()->get_sdu_lcid() == 0 && route_pdu) { int nbytes = srslte::sch_subh::MAC_CE_CONTRES_LEN; - if (mac_msg_ul.get()->get_payload_size() >= nbytes) { + if (mac_msg_ul.get()->get_payload_size() >= (uint32_t)nbytes) { uint8_t *ue_cri_ptr = (uint8_t *) &conres_id; uint8_t *pkt_ptr = mac_msg_ul.get()->get_sdu_ptr(); // Warning here: we want to include the for (int i = 0; i < nbytes; i++) { diff --git a/srsue/src/mac/demux.cc b/srsue/src/mac/demux.cc index 0b38b14a0..92614f03b 100644 --- a/srsue/src/mac/demux.cc +++ b/srsue/src/mac/demux.cc @@ -216,7 +216,7 @@ void demux::process_mch_pdu(srslte::mch_pdu *mch_msg){ } if(mch_msg->get()->is_sdu()) { uint32_t lcid = mch_msg->get()->get_sdu_lcid(); - if(lcid < 0 || lcid >= SRSLTE_N_MCH_LCIDS) { + if(lcid >= SRSLTE_N_MCH_LCIDS) { Error("Radio bearer id must be in [0:%d] - %d\n", SRSLTE_N_MCH_LCIDS, lcid); return; } @@ -230,7 +230,7 @@ void demux::process_mch_pdu(srslte::mch_pdu *mch_msg){ void demux::mch_start_rx(uint32_t lcid) { - if(lcid>=0 && lcid<32) { + if(lcid < 32) { Info("MCH Channel Setup: LCID=%d\n", lcid); mch_lcids[lcid] = 1; } else {