fix coverity scan issues in master

This commit is contained in:
Francisco Paisana 2020-04-28 14:38:48 +01:00 committed by Andre Puschmann
parent 485771749e
commit de4d58d8fe
8 changed files with 18 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -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);
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();
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));
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();
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_),
has_ext(has_ext_),
aligned(aligned_)
{
}
{}
template <class IntType>
SRSASN_CODE integer_packer<IntType>::pack(bit_ref& bref, IntType n)

View File

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

View File

@ -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));
// 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->config_security(rnti, lcid, sec_cfg);
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);
if (pdu) {
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);
char buf[32] = {};

View File

@ -328,7 +328,7 @@ private:
private:
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_t<plmn_search_proc> plmn_searcher;

View File

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