fix coverity scan issues in master

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

@ -246,6 +246,7 @@ public:
{ {
if (current_size >= MAX_N) { if (current_size >= MAX_N) {
log_error("Maximum size %d achieved for bounded_array.\n", MAX_N); log_error("Maximum size %d achieved for bounded_array.\n", MAX_N);
return;
} }
data_[current_size++] = elem; data_[current_size++] = elem;
} }

@ -295,8 +295,9 @@ private:
void sanitize_() void sanitize_()
{ {
size_t n = size() % bits_per_word; size_t n = size() % bits_per_word;
if (n != 0) { size_t nwords = nof_words_();
buffer[nof_words_() - 1] &= ~((~static_cast<word_t>(0)) << n); if (n != 0 and nwords > 0) {
buffer[nwords - 1] &= ~((~static_cast<word_t>(0)) << n);
} }
} }

@ -526,7 +526,7 @@ protected:
private: private:
int launch_counter = 0; int launch_counter = 0;
bool success = false; bool success = false;
Result result; Result result = {};
}; };
} // namespace srslte } // namespace srslte

@ -795,7 +795,7 @@ SRSASN_CODE pack_integer(bit_ref& bref, IntType n, IntType lb, IntType ub, bool
log_error("The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub); log_error("The condition lb <= n <= ub (%ld <= %ld <= %ld) was not met\n", (long)lb, (long)n, (long)ub);
return SRSASN_ERROR_ENCODE_FAIL; return SRSASN_ERROR_ENCODE_FAIL;
} }
bool lower_bounded = lb != std::numeric_limits<IntType>::min() or lb == 0; bool lower_bounded = lb != std::numeric_limits<IntType>::min() or std::is_unsigned<IntType>::value;
bool upper_bounded = ub != std::numeric_limits<IntType>::max(); bool upper_bounded = ub != std::numeric_limits<IntType>::max();
if (within_bounds and lower_bounded and upper_bounded) { if (within_bounds and lower_bounded and upper_bounded) {
@ -855,7 +855,7 @@ SRSASN_CODE unpack_integer(IntType& n, cbit_ref& bref, IntType lb, IntType ub, b
HANDLE_CODE(bref.unpack(within_bounds, 1)); HANDLE_CODE(bref.unpack(within_bounds, 1));
within_bounds = not within_bounds; within_bounds = not within_bounds;
} }
bool lower_bounded = lb != std::numeric_limits<IntType>::min() or lb == 0; bool lower_bounded = lb != std::numeric_limits<IntType>::min() or std::is_unsigned<IntType>::value;
bool upper_bounded = ub != std::numeric_limits<IntType>::max(); bool upper_bounded = ub != std::numeric_limits<IntType>::max();
if (within_bounds and lower_bounded and upper_bounded) { if (within_bounds and lower_bounded and upper_bounded) {
@ -913,8 +913,7 @@ integer_packer<IntType>::integer_packer(IntType lb_, IntType ub_, bool has_ext_,
ub(ub_), ub(ub_),
has_ext(has_ext_), has_ext(has_ext_),
aligned(aligned_) aligned(aligned_)
{ {}
}
template <class IntType> template <class IntType>
SRSASN_CODE integer_packer<IntType>::pack(bit_ref& bref, IntType n) SRSASN_CODE integer_packer<IntType>::pack(bit_ref& bref, IntType n)

@ -113,6 +113,7 @@ int open_socket(net_utils::addr_family ip_type, net_utils::socket_type socket_ty
if (fd == -1) { if (fd == -1) {
srslte::logmap::get("COMMON")->error("Failed to open %s socket.\n", net_utils::protocol_to_string(protocol)); srslte::logmap::get("COMMON")->error("Failed to open %s socket.\n", net_utils::protocol_to_string(protocol));
perror("Could not create socket\n"); perror("Could not create socket\n");
return -1;
} }
if (protocol == protocol_type::SCTP) { if (protocol == protocol_type::SCTP) {

@ -1910,7 +1910,8 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu)
rnti, lcid, srslte::make_rlc_config_t(conn_reconf->rr_cfg_ded.drb_to_add_mod_list[vec_idx].rlc_cfg)); rnti, lcid, srslte::make_rlc_config_t(conn_reconf->rr_cfg_ded.drb_to_add_mod_list[vec_idx].rlc_cfg));
// Configure DRB1 in PDCP // Configure DRB1 in PDCP
srslte::pdcp_config_t pdcp_cnfg_drb = srslte::make_drb_pdcp_config_t(drb_id, false, conn_reconf->rr_cfg_ded.drb_to_add_mod_list[vec_idx].pdcp_cfg); srslte::pdcp_config_t pdcp_cnfg_drb =
srslte::make_drb_pdcp_config_t(drb_id, false, conn_reconf->rr_cfg_ded.drb_to_add_mod_list[vec_idx].pdcp_cfg);
parent->pdcp->add_bearer(rnti, lcid, pdcp_cnfg_drb); parent->pdcp->add_bearer(rnti, lcid, pdcp_cnfg_drb);
parent->pdcp->config_security(rnti, lcid, sec_cfg); parent->pdcp->config_security(rnti, lcid, sec_cfg);
parent->pdcp->enable_integrity(rnti, lcid); parent->pdcp->enable_integrity(rnti, lcid);
@ -2341,7 +2342,10 @@ void rrc::ue::send_dl_ccch(dl_ccch_msg_s* dl_ccch_msg)
srslte::unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool); srslte::unique_byte_buffer_t pdu = srslte::allocate_unique_buffer(*pool);
if (pdu) { if (pdu) {
asn1::bit_ref bref(pdu->msg, pdu->get_tailroom()); asn1::bit_ref bref(pdu->msg, pdu->get_tailroom());
dl_ccch_msg->pack(bref); if (dl_ccch_msg->pack(bref) != asn1::SRSASN_SUCCESS) {
parent->rrc_log->error_hex(pdu->msg, pdu->N_bytes, "Failed to pack DL-CCCH-Msg:\n");
return;
}
pdu->N_bytes = 1u + (uint32_t)bref.distance_bytes(pdu->msg); pdu->N_bytes = 1u + (uint32_t)bref.distance_bytes(pdu->msg);
char buf[32] = {}; char buf[32] = {};

@ -328,7 +328,7 @@ private:
private: private:
nas* nas_ptr; nas* nas_ptr;
enum class state_t { plmn_search, rrc_connect } state; enum class state_t { plmn_search, rrc_connect } state = state_t::plmn_search;
}; };
srslte::proc_manager_list_t callbacks; srslte::proc_manager_list_t callbacks;
srslte::proc_t<plmn_search_proc> plmn_searcher; srslte::proc_t<plmn_search_proc> plmn_searcher;

@ -626,9 +626,8 @@ void gw::del_ipv6_addr(struct in6_addr* in6p)
} }
out: out:
if (fd < 0) { if (fd >= 0) {
close(fd); close(fd);
} }
return;
} }
} // namespace srsue } // namespace srsue

Loading…
Cancel
Save