From dd336c53eacde0c2a256aa5081214e6038c0a42d Mon Sep 17 00:00:00 2001 From: Francisco Date: Mon, 22 Mar 2021 20:34:18 +0000 Subject: [PATCH] changed srsran_warning to srsran_expect. Applied new macro to rlc am --- lib/include/srsran/common/srsran_assert.h | 6 +++--- lib/include/srsran/common/tti_point.h | 10 ++++------ lib/include/srsran/upper/rlc_am_lte.h | 7 ++++--- lib/src/upper/rlc_am_lte.cc | 4 ++-- srsenb/src/main.cc | 2 +- srsue/src/main.cc | 1 + 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/include/srsran/common/srsran_assert.h b/lib/include/srsran/common/srsran_assert.h index f9f3e8646..e2b5a462b 100644 --- a/lib/include/srsran/common/srsran_assert.h +++ b/lib/include/srsran/common/srsran_assert.h @@ -32,11 +32,11 @@ #ifdef STOP_ON_WARNING -#define srsran_warning(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) +#define srsran_expect(condition, fmt, ...) srsran_assert(condition, fmt, ##__VA_ARGS__) #else // STOP_ON_WARNING -#define srsran_warning(condition, fmt, ...) \ +#define srsran_expect(condition, fmt, ...) \ do { \ if (srsran_unlikely(not(condition))) { \ srslog::fetch_basic_logger("ALL").warning("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__); \ @@ -51,7 +51,7 @@ do { \ } while (0) -#define srsran_warning(condition, fmt, ...) \ +#define srsran_expect(condition, fmt, ...) \ do { \ } while (0) diff --git a/lib/include/srsran/common/tti_point.h b/lib/include/srsran/common/tti_point.h index a94adf779..08151f1a2 100644 --- a/lib/include/srsran/common/tti_point.h +++ b/lib/include/srsran/common/tti_point.h @@ -15,6 +15,7 @@ #include "srsran/adt/interval.h" #include "srsran/common/common.h" +#include "srsran/common/srsran_assert.h" #include "srsran/srslog/srslog.h" #include #include @@ -23,16 +24,13 @@ namespace srsran { struct tti_point { constexpr tti_point() = default; - explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240u) + explicit tti_point(uint32_t tti_val_) : tti_val(tti_val_ % 10240U) { if (tti_val_ > std::numeric_limits::max() / 2) { // there was a overflow at tti initialization uint32_t diff = std::numeric_limits::max() - tti_val_; - if (diff < 10240) { - tti_val = 10240 - diff - 1; - } else { - srslog::fetch_basic_logger("COMMON").error("Invalid TTI point assigned"); - } + srsran_expect(diff < 10240, "Invalid TTI point assigned"); + tti_val = 10240 - diff - 1; } } void reset() { tti_val = std::numeric_limits::max(); } diff --git a/lib/include/srsran/upper/rlc_am_lte.h b/lib/include/srsran/upper/rlc_am_lte.h index 202240138..5f273c64a 100644 --- a/lib/include/srsran/upper/rlc_am_lte.h +++ b/lib/include/srsran/upper/rlc_am_lte.h @@ -17,6 +17,7 @@ #include "srsran/adt/circular_array.h" #include "srsran/common/buffer_pool.h" #include "srsran/common/common.h" +#include "srsran/common/srsran_assert.h" #include "srsran/common/task_scheduler.h" #include "srsran/common/timeout.h" #include "srsran/interfaces/pdcp_interface_types.h" @@ -75,7 +76,7 @@ struct rlc_ringbuffer_t { rlc_ringbuffer_t() { clear(); } T& add_pdu(size_t sn) { - assert(not has_sn(sn)); + srsran_expect(not has_sn(sn), "The same SN=%d should not be added twice", sn); window[sn].rlc_sn = sn; active_flag[sn] = true; count++; @@ -83,14 +84,14 @@ struct rlc_ringbuffer_t { } void remove_pdu(size_t sn) { - assert(active_flag[sn]); + srsran_expect(has_sn(sn), "The removed SN=%d is not in the window", sn); window[sn] = {}; active_flag[sn] = false; count--; } T& operator[](size_t sn) { - assert(has_sn(sn)); + srsran_expect(has_sn(sn), "The accessed SN=%d is not in the window", sn); return window[sn]; } size_t size() const { return count; } diff --git a/lib/src/upper/rlc_am_lte.cc b/lib/src/upper/rlc_am_lte.cc index bd6a8a83c..5258806d4 100644 --- a/lib/src/upper/rlc_am_lte.cc +++ b/lib/src/upper/rlc_am_lte.cc @@ -820,7 +820,7 @@ int rlc_am_lte::rlc_am_lte_tx::build_segment(uint8_t* payload, uint32_t nof_byte } // Santity check we don't pack beyond the provided buffer - assert(head_len + (retx.so_end - retx.so_start) <= nof_bytes); + srsran_expect(head_len + (retx.so_end - retx.so_start) <= nof_bytes, "The provided buffer was overflown."); // Update retx_queue if (tx_window[retx.sn].buf->N_bytes == retx.so_end) { @@ -1129,7 +1129,7 @@ void rlc_am_lte::rlc_am_lte_tx::handle_control_pdu(uint8_t* payload, uint32_t no auto& pdu = tx_window[i]; if (!retx_queue.has_sn(i)) { rlc_amd_retx_t& retx = retx_queue.push(); - assert(tx_window[i].rlc_sn == i); + srsran_expect(tx_window[i].rlc_sn == i, "Incorrect RLC SN=%d!=%d being accessed", tx_window[i].rlc_sn, i); retx.sn = i; retx.is_segment = false; retx.so_start = 0; diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 4f699cbb2..145603f9b 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -512,7 +512,7 @@ int main(int argc, char* argv[]) // Start the log backend. srslog::init(); - srslog::fetch_basic_logger("COMMON").set_level(srslog::basic_levels::info); + srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning); srsran::log_args(argc, argv, "ENB"); srsran::check_scaling_governor(args.rf.device_name); diff --git a/srsue/src/main.cc b/srsue/src/main.cc index 66a44a02b..a8fa32a91 100644 --- a/srsue/src/main.cc +++ b/srsue/src/main.cc @@ -663,6 +663,7 @@ int main(int argc, char* argv[]) // Start the log backend. srslog::init(); + srslog::fetch_basic_logger("ALL").set_level(srslog::basic_levels::warning); srsran::log_args(argc, argv, "UE"); srsran::check_scaling_governor(args.rf.device_name);