From f8c6f55cac8b46a9bcc2e133ba41e932b49dca25 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 28 Apr 2020 15:00:08 +0100 Subject: [PATCH] fix uninit var usages and signed bit manipulations --- lib/include/srslte/common/stack_procedure.h | 2 +- lib/include/srslte/interfaces/sched_interface.h | 2 +- lib/include/srslte/mac/pdu.h | 3 +-- lib/src/asn1/asn1_utils.cc | 10 +++++----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/include/srslte/common/stack_procedure.h b/lib/include/srslte/common/stack_procedure.h index aae547699..38606f0f6 100644 --- a/lib/include/srslte/common/stack_procedure.h +++ b/lib/include/srslte/common/stack_procedure.h @@ -335,7 +335,7 @@ public: { if (is_busy()) { fut->clear(); - return fut; + return false; } proc_state = proc_base_t::proc_status_t::on_going; *fut = get_future(); diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index ab05e5d25..396e95c73 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -136,7 +136,7 @@ public: /* ue capabilities, etc */ uint32_t maxharq_tx = 5; bool continuous_pusch; - srslte_uci_offset_cfg_t uci_offset; + srslte_uci_offset_cfg_t uci_offset = {}; srslte_pucch_cfg_t pucch_cfg = {}; uint32_t aperiodic_cqi_period = 0; // if 0 is periodic CQI srslte_dl_cfg_t dl_cfg; diff --git a/lib/include/srslte/mac/pdu.h b/lib/include/srslte/mac/pdu.h index dba2da208..ee24b99ed 100644 --- a/lib/include/srslte/mac/pdu.h +++ b/lib/include/srslte/mac/pdu.h @@ -271,7 +271,6 @@ template class subh { public: - subh() {} virtual ~subh() {} virtual bool read_subheader(uint8_t** ptr) = 0; @@ -280,7 +279,7 @@ public: virtual void write_payload(uint8_t** ptr) = 0; virtual void fprint(FILE* stream) = 0; - pdu* parent; + pdu* parent = nullptr; private: virtual void init() = 0; diff --git a/lib/src/asn1/asn1_utils.cc b/lib/src/asn1/asn1_utils.cc index c5c7a682c..f3fe6ed2e 100644 --- a/lib/src/asn1/asn1_utils.cc +++ b/lib/src/asn1/asn1_utils.cc @@ -244,7 +244,7 @@ SRSASN_CODE bit_ref_impl::unpack_bytes(uint8_t* buf, uint32_t n_bytes) ptr += n_bytes; } else { for (uint32_t i = 0; i < n_bytes; ++i) { - unpack(buf[i], 8); + HANDLE_CODE(unpack(buf[i], 8)); } } return SRSASN_SUCCESS; @@ -1177,7 +1177,7 @@ void from_number(uint8_t* ptr, uint64_t number, uint32_t nbits) log_error("bitstring of size=%d does not fit in an uint64_t\n", nbits); return; } - uint32_t nof_bytes = (uint32_t)ceilf(nbits / 8.0f); + uint32_t nof_bytes = ceil_frac(nbits, 8u); for (uint32_t i = 0; i < nof_bytes; ++i) { ptr[i] = (number >> (i * 8u)) & 0xFFu; } @@ -1198,14 +1198,14 @@ std::string to_string(const uint8_t* ptr, uint32_t nbits) uint64_t to_number(const uint8_t* ptr, uint32_t nbits) { - if (nbits > 64) { + if (nbits > 64u) { log_error("bitstring of size=%d does not fit in an uint64_t\n", nbits); return 0; } uint64_t val = 0; - uint32_t nof_bytes = (uint32_t)ceilf(nbits / 8.0f); + uint32_t nof_bytes = ceil_frac(nbits, 8u); for (uint32_t i = 0; i < nof_bytes; ++i) { - val += ptr[i] << (i * 8); + val += ptr[i] << (i * 8u); } return val; }