fix uninit var usages and signed bit manipulations

master
Francisco Paisana 5 years ago committed by Andre Puschmann
parent de4d58d8fe
commit f8c6f55cac

@ -335,7 +335,7 @@ public:
{ {
if (is_busy()) { if (is_busy()) {
fut->clear(); fut->clear();
return fut; return false;
} }
proc_state = proc_base_t::proc_status_t::on_going; proc_state = proc_base_t::proc_status_t::on_going;
*fut = get_future(); *fut = get_future();

@ -136,7 +136,7 @@ public:
/* ue capabilities, etc */ /* ue capabilities, etc */
uint32_t maxharq_tx = 5; uint32_t maxharq_tx = 5;
bool continuous_pusch; bool continuous_pusch;
srslte_uci_offset_cfg_t uci_offset; srslte_uci_offset_cfg_t uci_offset = {};
srslte_pucch_cfg_t pucch_cfg = {}; srslte_pucch_cfg_t pucch_cfg = {};
uint32_t aperiodic_cqi_period = 0; // if 0 is periodic CQI uint32_t aperiodic_cqi_period = 0; // if 0 is periodic CQI
srslte_dl_cfg_t dl_cfg; srslte_dl_cfg_t dl_cfg;

@ -271,7 +271,6 @@ template <class SubH>
class subh class subh
{ {
public: public:
subh() {}
virtual ~subh() {} virtual ~subh() {}
virtual bool read_subheader(uint8_t** ptr) = 0; virtual bool read_subheader(uint8_t** ptr) = 0;
@ -280,7 +279,7 @@ public:
virtual void write_payload(uint8_t** ptr) = 0; virtual void write_payload(uint8_t** ptr) = 0;
virtual void fprint(FILE* stream) = 0; virtual void fprint(FILE* stream) = 0;
pdu<SubH>* parent; pdu<SubH>* parent = nullptr;
private: private:
virtual void init() = 0; virtual void init() = 0;

@ -244,7 +244,7 @@ SRSASN_CODE bit_ref_impl<Ptr>::unpack_bytes(uint8_t* buf, uint32_t n_bytes)
ptr += n_bytes; ptr += n_bytes;
} else { } else {
for (uint32_t i = 0; i < n_bytes; ++i) { for (uint32_t i = 0; i < n_bytes; ++i) {
unpack(buf[i], 8); HANDLE_CODE(unpack(buf[i], 8));
} }
} }
return SRSASN_SUCCESS; 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); log_error("bitstring of size=%d does not fit in an uint64_t\n", nbits);
return; 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) { for (uint32_t i = 0; i < nof_bytes; ++i) {
ptr[i] = (number >> (i * 8u)) & 0xFFu; 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) 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); log_error("bitstring of size=%d does not fit in an uint64_t\n", nbits);
return 0; return 0;
} }
uint64_t val = 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) { for (uint32_t i = 0; i < nof_bytes; ++i) {
val += ptr[i] << (i * 8); val += ptr[i] << (i * 8u);
} }
return val; return val;
} }

Loading…
Cancel
Save