From aaa333c1ff077d7c4b24664cb1ac0970132fb50d Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Tue, 3 Mar 2020 19:51:26 +0000 Subject: [PATCH] removed some clang warnings --- lib/src/asn1/asn1_utils.cc | 32 ++++++++++++++++---------------- lib/src/asn1/rrc_asn1_utils.cc | 4 ++-- lib/test/asn1/rrc_asn1_test.cc | 4 ++-- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/src/asn1/asn1_utils.cc b/lib/src/asn1/asn1_utils.cc index 7e7965d2e..628b258f5 100644 --- a/lib/src/asn1/asn1_utils.cc +++ b/lib/src/asn1/asn1_utils.cc @@ -148,13 +148,13 @@ SRSASN_CODE bit_ref::pack(uint32_t val, uint32_t n_bits) val = val & mask; uint8_t keepmask = ((uint8_t)-1) - (uint8_t)((1u << (8u - offset)) - 1u); if ((uint32_t)(8 - offset) > n_bits) { - uint8_t bit = (uint8_t)(val << (8u - offset - n_bits)); - *ptr = ((*ptr) & keepmask) + bit; + auto bit = static_cast(val << (8u - offset - n_bits)); + *ptr = ((*ptr) & keepmask) + bit; offset += n_bits; n_bits = 0; } else { - uint8_t bit = (uint8_t)(val >> (n_bits - 8u + offset)); - *ptr = (*ptr & keepmask) + bit; + auto bit = static_cast(val >> (n_bits - 8u + offset)); + *ptr = (*ptr & keepmask) + bit; n_bits -= (8 - offset); offset = 0; ptr++; @@ -182,7 +182,7 @@ SRSASN_CODE unpack_bits(T& val, Ptr& ptr, uint8_t& offset, const uint8_t* max_pt offset += n_bits; n_bits = 0; } else { - uint8_t mask = (uint8_t)((1u << (8u - offset)) - 1u); + auto mask = static_cast((1u << (8u - offset)) - 1u); val += ((uint32_t)((*ptr) & mask)) << (n_bits - 8 + offset); n_bits -= 8 - offset; offset = 0; @@ -321,7 +321,7 @@ SRSASN_CODE bit_ref::align_bytes_zero() log_error("Buffer size limit was achieved\n"); return SRSASN_ERROR_ENCODE_FAIL; } - uint8_t mask = (uint8_t)(256u - (1u << (8u - offset))); + auto mask = static_cast(256u - (1u << (8u - offset))); *ptr &= mask; offset = 0; ptr++; @@ -336,7 +336,7 @@ SRSASN_CODE pack_unsupported_ext_flag(bit_ref& bref, bool ext) { HANDLE_CODE(bref.pack(ext, 1)); if (ext) { - log_error("asn1 error: ASN extensions not currently supported\n"); + log_error("ASN extensions not currently supported\n"); return SRSASN_ERROR_ENCODE_FAIL; } return SRSASN_SUCCESS; @@ -346,7 +346,7 @@ SRSASN_CODE unpack_unsupported_ext_flag(bool& ext, bit_ref& bref) { SRSASN_CODE ret = bref.unpack(ext, 1); if (ext) { - log_error("asn1 error: ASN extensions not currently supported\n"); + log_error("ASN extensions not currently supported\n"); return SRSASN_ERROR_DECODE_FAIL; } return ret; @@ -959,7 +959,7 @@ void number_to_octstring(uint8_t* ptr, uint64_t number, uint32_t nbytes) return; } for (uint32_t i = 0; i < nbytes; ++i) { - ptr[nbytes - 1 - i] = (number >> (uint64_t)(i * 8u)) & 0xFF; + ptr[nbytes - 1 - i] = (number >> (uint64_t)(i * 8u)) & 0xFFu; } } @@ -1184,7 +1184,7 @@ void from_number(uint8_t* ptr, uint64_t number, uint32_t nbits) } uint32_t offset = nbits % 8; // clean up any extra set bit if (offset > 0) { - ptr[nof_bytes - 1] &= (uint8_t)((1 << offset) - 1); + ptr[nof_bytes - 1] &= (uint8_t)((1u << offset) - 1u); } } @@ -1234,7 +1234,7 @@ namespace asn_string_utils { size_t get_nof_bits_per_char(size_t lb, size_t ub, bool aligned) { size_t N = ub - lb + 1; - size_t b = (size_t)ceilf(log2(N)); // B + auto b = (size_t)ceilf(log2(N)); // B if (aligned) { b = (size_t)pow(2, ceilf(log2(b))); // B2 } @@ -1277,8 +1277,8 @@ pack(bit_ref& bref, const std::string& s, size_t lb, size_t ub, size_t alb, size if (octet_aligned) { bref.align_bytes_zero(); } - for (uint32_t i = 0; i < s.size(); ++i) { - HANDLE_CODE(bref.pack(s[i], b)); + for (char c : s) { + HANDLE_CODE(bref.pack(c, b)); } return SRSASN_SUCCESS; } @@ -1308,8 +1308,8 @@ SRSASN_CODE unpack(std::string& s, cbit_ref& bref, size_t lb, size_t ub, size_t if (octet_aligned) { bref.align_bytes(); } - for (uint32_t i = 0; i < s.size(); ++i) { - HANDLE_CODE(bref.unpack(s[i], b)); + for (char& c : s) { + HANDLE_CODE(bref.unpack(c, b)); } return SRSASN_SUCCESS; } @@ -1460,7 +1460,7 @@ void json_writer::write_fieldname(const std::string& fieldname) } else if (sep == NEWLINE) { ss << "\n" << ident; } - if (fieldname.size() > 0) { + if (not fieldname.empty()) { ss << "\"" << fieldname << "\": "; } sep = NONE; diff --git a/lib/src/asn1/rrc_asn1_utils.cc b/lib/src/asn1/rrc_asn1_utils.cc index 1d6762a48..c8d388c76 100644 --- a/lib/src/asn1/rrc_asn1_utils.cc +++ b/lib/src/asn1/rrc_asn1_utils.cc @@ -152,7 +152,7 @@ srslte::rlc_config_t make_rlc_config_t(const asn1::rrc::srb_to_add_mod_s& asn1_t if (asn1_type.srb_id <= 2) { return rlc_config_t::srb_config(asn1_type.srb_id); } else { - srslte::logmap::get("ASN1::RRC")->error("SRB %d does not support default initialization type\n", asn1_type.srb_id); + asn1::log_error("SRB %d does not support default initialization type\n", asn1_type.srb_id); return rlc_config_t(); } } @@ -351,7 +351,7 @@ srsenb::sched_interface::ant_info_ded_t make_ant_info_ded(const asn1::rrc::ant_i ant_ded.codebook_subset_restrict = asn1code.n4_tx_ant_tm6().to_number(); break; default: - srslte::logmap::get("ASN1::RRC")->error("Failed to convert antenna codebook type to number\n"); + asn1::log_error("Failed to convert antenna codebook type to number\n"); } } ant_ded.ue_tx_ant_sel = srsenb::sched_interface::ant_info_ded_t::ue_tx_ant_sel_t::release; diff --git a/lib/test/asn1/rrc_asn1_test.cc b/lib/test/asn1/rrc_asn1_test.cc index f5054a361..5e58d69f5 100644 --- a/lib/test/asn1/rrc_asn1_test.cc +++ b/lib/test/asn1/rrc_asn1_test.cc @@ -36,9 +36,9 @@ int test_generic() // test logger handler { - srslte::scoped_log null_log("ASN1::RRC"); + srslte::scoped_log null_log("ASN1"); null_log->set_level(srslte::LOG_LEVEL_INFO); - srslte::logmap::get("ASN1::RRC")->info("This is a console test to see if the RRC logger is working fine\n"); + asn1::log_info("This is a console test to see if the RRC logger is working fine\n"); TESTASSERT(null_log->last_log_msg == "This is a console test to see if the RRC logger is working fine\n"); TESTASSERT(null_log->last_log_level == srslte::LOG_LEVEL_INFO); // go back to original logger