Some LGTM fixes (#3564)

* Fix LGTM issues

* ue: add logging to switch on function

* Fix new LGTM issues
master
Ismael Gomez 3 years ago committed by GitHub
parent 2a2518b7e4
commit d972fb368c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -24,7 +24,7 @@ class rlc_pcap
public:
rlc_pcap() {}
void enable(bool en);
void open(const char* filename, rlc_config_t config);
void open(const char* filename, const rlc_config_t& config);
void close();
void set_ue_id(uint16_t ue_id);

@ -36,9 +36,9 @@ public:
virtual void add_user(uint16_t rnti) = 0;
virtual void rem_user(uint16_t rnti) = 0;
virtual void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual void add_bearer(uint16_t rnti, uint32_t lcid, const srsran::pdcp_config_t& cnfg) = 0;
virtual void del_bearer(uint16_t rnti, uint32_t lcid) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0;
virtual void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;
virtual void enable_integrity(uint16_t rnti, uint32_t lcid) = 0;
virtual void enable_encryption(uint16_t rnti, uint32_t lcid) = 0;
virtual void send_status_report(uint16_t rnti) = 0;

@ -26,7 +26,7 @@ public:
virtual void reset() = 0;
virtual void set_enabled(uint32_t lcid, bool enabled) = 0;
virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1) = 0;
virtual int add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) = 0;
virtual int add_bearer(uint32_t lcid, const srsran::pdcp_config_t& cnfg) = 0;
virtual void del_bearer(uint32_t lcid) = 0;
virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0;
virtual void config_security(uint32_t lcid, const srsran::as_security_config_t& sec_cfg) = 0;

@ -39,8 +39,8 @@ public:
void set_enabled(uint32_t lcid, bool enabled) override;
void write_sdu(uint32_t lcid, unique_byte_buffer_t sdu, int sn = -1) override;
void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu);
int add_bearer(uint32_t lcid, pdcp_config_t cnfg) override;
void add_bearer_mrb(uint32_t lcid, pdcp_config_t cnfg);
int add_bearer(uint32_t lcid, const pdcp_config_t& cnfg) override;
void add_bearer_mrb(uint32_t lcid, const pdcp_config_t& cnfg);
void del_bearer(uint32_t lcid) override;
void change_lcid(uint32_t old_lcid, uint32_t new_lcid) override;
void config_security(uint32_t lcid, const as_security_config_t& sec_cfg) override;

@ -2092,12 +2092,10 @@ LIBLTE_ERROR_ENUM liblte_mme_unpack_network_name_ie(uint8** ie_ptr, LIBLTE_MME_N
if (tmp_char == 0x0A || tmp_char == 0x0D || (tmp_char >= 0x20 && tmp_char <= 0x3F) ||
(tmp_char >= 0x41 && tmp_char <= 0x5A) || (tmp_char >= 0x61 && tmp_char <= 0x7A)) {
if (str_cnt < LIBLTE_STRING_LEN) {
net_name->name[str_cnt] = tmp_char;
str_cnt++;
}
}
}
if (0 == bit_offset || (1 == bit_offset && 0 == spare_field)) {
if (0 == bit_offset) {

@ -22,7 +22,7 @@ void rlc_pcap::enable(bool en)
enable_write = true;
}
void rlc_pcap::open(const char* filename, rlc_config_t config)
void rlc_pcap::open(const char* filename, const rlc_config_t& config)
{
fprintf(stdout, "Opening RLC PCAP with DLT=%d\n", UDP_DLT);
pcap_file = DLT_PCAP_Open(UDP_DLT, filename);

@ -99,7 +99,7 @@ void pdcp::write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu)
}
}
int pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
int pdcp::add_bearer(uint32_t lcid, const pdcp_config_t& cfg)
{
if (valid_lcid(lcid)) {
return pdcp_array[lcid]->configure(cfg) ? SRSRAN_SUCCESS : SRSRAN_ERROR;
@ -134,7 +134,7 @@ int pdcp::add_bearer(uint32_t lcid, pdcp_config_t cfg)
return SRSRAN_SUCCESS;
}
void pdcp::add_bearer_mrb(uint32_t lcid, pdcp_config_t cfg)
void pdcp::add_bearer_mrb(uint32_t lcid, const pdcp_config_t& cfg)
{
if (not valid_mch_lcid(lcid)) {
std::unique_ptr<pdcp_entity_lte> entity;

@ -314,8 +314,7 @@ int srsran_refsignal_dmrs_pusch_pregen_put(srsran_refsignal_ul_t* q,
{
uint32_t sf_idx = sf_cfg->tti % 10;
if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && sf_idx < SRSRAN_NOF_SF_X_FRAME &&
pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
if (srsran_dft_precoding_valid_prb(pusch_cfg->grant.L_prb) && pusch_cfg->grant.n_dmrs < SRSRAN_NOF_CSHIFT) {
srsran_refsignal_dmrs_pusch_put(
q, pusch_cfg, pregen->r[pusch_cfg->grant.n_dmrs][sf_idx][pusch_cfg->grant.L_prb], sf_symbols);
return SRSRAN_SUCCESS;

@ -270,7 +270,7 @@ static int zc_sequence_nr_r_uv_arg(uint32_t M_zc, uint32_t u, uint32_t v, cf_t*
static void zc_sequence_generate(uint32_t M_zc, float alpha, const cf_t* tmp_arg, cf_t* sequence)
{
for (uint32_t i = 0; i < M_zc; i++) {
sequence[i] = cexpf(I * (tmp_arg[i] + alpha * (float)i));
sequence[i] = cexpf(I * (tmp_arg[i] + alpha * (cf_t)i));
}
}

@ -115,7 +115,7 @@ int get_code_params(srsran_polar_code_t* c, const uint16_t K, const uint16_t E,
// number of parity check bits (nPC) and parity check bits of minimum bandwidth nWmPC
uint8_t nPC = 0;
uint8_t nWmPC = 0;
if (K >= 18 && K <= 25) {
if (K <= 25) {
nPC = 3;
if (E > K + 189) {
nWmPC = 1;

@ -131,7 +131,7 @@ int compute_node_type(void* p,
}
uint16_t code_stage_size = 0;
uint16_t code_size_log_s = 0;
for (s = 1; s < code_size_log + 1; s++) {
for (s = 1; s < (uint8_t)(code_size_log + 1); s++) {
code_size_log_s = code_size_log - s;
code_stage_size = (1U << code_size_log_s);
for (uint16_t j = 0; j < code_stage_size; j++) {

@ -186,11 +186,6 @@ int srsran_phich_decode(srsran_phich_t* q,
uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d", sf_idx);
return SRSRAN_ERROR_INVALID_INPUTS;
}
if (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq);
@ -319,11 +314,6 @@ int srsran_phich_encode(srsran_phich_t* q,
uint32_t sf_idx = sf->tti % 10;
if (sf_idx >= SRSRAN_NOF_SF_X_FRAME) {
ERROR("Invalid nslot %d", sf_idx);
return SRSRAN_ERROR_INVALID_INPUTS;
}
if (SRSRAN_CP_ISEXT(q->cell.cp)) {
if (n_phich.nseq >= SRSRAN_PHICH_EXT_NSEQUENCES) {
ERROR("Invalid nseq %d", n_phich.nseq);

@ -143,7 +143,7 @@ int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg,
// Row 1
if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant);
} else if (m < SRSRAN_MAX_NOF_TIME_RA && m < cfg->nof_common_time_ra) {
} else if (m < cfg->nof_common_time_ra) {
ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant);
} else {
ERROR("Time domain resource selection (m=%d) exceeds the maximum value (%d)",
@ -156,7 +156,7 @@ int srsran_ra_ul_nr_time(const srsran_sch_hl_cfg_nr_t* cfg,
// Row 2
if (cfg->nof_common_time_ra == 0) {
srsran_ra_ul_nr_pusch_time_resource_default_A(cfg->scs_cfg, m, grant);
} else if (m < SRSRAN_MAX_NOF_TIME_RA) {
} else {
ra_ul_nr_time_hl(&cfg->common_time_ra[m], grant);
}
} else if ((rnti_type == srsran_rnti_type_c || rnti_type == srsran_rnti_type_mcs_c ||

@ -143,12 +143,7 @@ int srsran_resample_arb_compute(srsran_resample_arb_t* q, cf_t* input, cf_t* out
filter_input, srsran_resample_arb_polyfilt[(idx + 1) % SRSRAN_RESAMPLE_ARB_N], SRSRAN_RESAMPLE_ARB_M);
}
// TODO: this condition is never true
if (idx == SRSRAN_RESAMPLE_ARB_N) {
*output = res1;
} else {
*output = (q->interpolate) ? (res1 + (res2 - res1) * frac) : res1;
}
output++;
n_out++;

@ -399,7 +399,7 @@ bool radio::tx(rf_buffer_interface& buffer, const rf_timestamp_interface& tx_tim
uint32_t nof_samples = buffer.get_nof_samples();
// Check that number of the interpolated samples does not exceed the buffer size
if (ratio > 1 && nof_samples * ratio > tx_buffer[0].size()) {
if (ratio > 1 && (size_t)nof_samples * (size_t)ratio > tx_buffer[0].size()) {
// This is a corner case that could happen during sample rate change transitions, as it does not have a negative
// impact, log it as info.
fmt::memory_buffer buff;

@ -154,8 +154,10 @@ public:
const sched_interface::dl_sched_pdu_t pdu[sched_interface::MAX_RLC_PDU_LIST],
uint32_t nof_pdu_elems,
uint32_t grant_size);
uint8_t*
generate_mch_pdu(uint32_t harq_pid, sched_interface::dl_pdu_mch_t sched, uint32_t nof_pdu_elems, uint32_t grant_size);
uint8_t* generate_mch_pdu(uint32_t harq_pid,
const sched_interface::dl_pdu_mch_t& sched,
uint32_t nof_pdu_elems,
uint32_t grant_size);
srsran_softbuffer_tx_t* get_tx_softbuffer(uint32_t enb_cc_idx, uint32_t harq_process, uint32_t tb_idx);
srsran_softbuffer_rx_t* get_rx_softbuffer(uint32_t enb_cc_idx, uint32_t tti);

@ -26,6 +26,16 @@ class security_cfg_handler
{
public:
explicit security_cfg_handler(const rrc_cfg_t& cfg_) : cfg(&cfg_), logger(srslog::fetch_basic_logger("RRC")) {}
explicit security_cfg_handler(const security_cfg_handler& other) : logger(srslog::fetch_basic_logger("RRC"))
{
cfg = other.cfg;
k_enb_present = other.k_enb_present;
security_capabilities = other.security_capabilities;
std::copy(other.k_enb, other.k_enb + 32, k_enb);
sec_cfg = other.sec_cfg;
ncc = other.ncc;
}
security_cfg_handler& operator=(const security_cfg_handler& other)
{
cfg = other.cfg;

@ -156,7 +156,7 @@ bool paging_manager::add_paging_record(uint32_t ueid, const asn1::rrc::paging_re
subframe_info& locked_sf = sf_pending_pcch[static_cast<size_t>(sf_key)];
std::lock_guard<std::mutex> lock(locked_sf.mutex);
size_t sfn_cycle_idx = (T / N) * (ueid % N);
size_t sfn_cycle_idx = ((size_t)T / (size_t)N) * (size_t)(ueid % N);
pcch_info& pending_pcch = locked_sf.pending_paging[sfn_cycle_idx];
auto& record_list = pending_pcch.pcch_msg.msg.c1().paging().paging_record_list;

@ -49,9 +49,9 @@ public:
void add_user(uint16_t rnti) override;
void rem_user(uint16_t rnti) override;
void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn = -1) override;
void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) override;
void add_bearer(uint16_t rnti, uint32_t lcid, const srsran::pdcp_config_t& cnfg) override;
void del_bearer(uint16_t rnti, uint32_t lcid) override;
void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t cfg_sec) override;
void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& cfg_sec) override;
void enable_integrity(uint16_t rnti, uint32_t lcid) override;
void enable_encryption(uint16_t rnti, uint32_t lcid) override;
bool get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) override;

@ -569,7 +569,7 @@ uint8_t* ue::generate_pdu(uint32_t enb_cc_idx,
}
uint8_t* ue::generate_mch_pdu(uint32_t harq_pid,
sched_interface::dl_pdu_mch_t sched_,
const sched_interface::dl_pdu_mch_t& sched_,
uint32_t nof_pdu_elems,
uint32_t grant_size)
{

@ -68,7 +68,7 @@ void pdcp::rem_user(uint16_t rnti)
}
}
void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cfg)
void pdcp::add_bearer(uint16_t rnti, uint32_t lcid, const srsran::pdcp_config_t& cfg)
{
if (users.count(rnti)) {
if (rnti != SRSRAN_MRNTI) {
@ -100,7 +100,7 @@ void pdcp::reset(uint16_t rnti)
}
}
void pdcp::config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg)
void pdcp::config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg)
{
if (users.count(rnti)) {
users[rnti].pdcp->config_security(lcid, sec_cfg);

@ -45,9 +45,9 @@ public:
void add_user(uint16_t rnti) override {}
void rem_user(uint16_t rnti) override {}
void write_sdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t sdu, int pdcp_sn) override {}
void add_bearer(uint16_t rnti, uint32_t lcid, srsran::pdcp_config_t cnfg) override {}
void add_bearer(uint16_t rnti, uint32_t lcid, const srsran::pdcp_config_t& cnfg) override {}
void del_bearer(uint16_t rnti, uint32_t lcid) override {}
void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg_) override {}
void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg_) override {}
void enable_integrity(uint16_t rnti, uint32_t lcid) override {}
void enable_encryption(uint16_t rnti, uint32_t lcid) override {}
bool get_bearer_state(uint16_t rnti, uint32_t lcid, srsran::pdcp_lte_state_t* state) override { return true; }

@ -140,7 +140,7 @@ public:
}
void enable_integrity(uint16_t rnti, uint32_t lcid) override { bearers[rnti][lcid].enable_integrity = true; }
void enable_encryption(uint16_t rnti, uint32_t lcid) override { bearers[rnti][lcid].enable_encryption = true; }
void config_security(uint16_t rnti, uint32_t lcid, srsran::as_security_config_t sec_cfg_) override
void config_security(uint16_t rnti, uint32_t lcid, const srsran::as_security_config_t& sec_cfg_) override
{
bearers[rnti][lcid].sec_cfg = sec_cfg_;
}

@ -55,7 +55,7 @@ void intra_measure_base::init_generic(uint32_t cc_idx_, const args_t& args)
// Reallocate only if the required capacity exceds the new requirement
if (ring_buffer.capacity < max_required_bytes) {
search_buffer.resize(context.meas_len_ms * context.sf_len);
search_buffer.resize((size_t)context.meas_len_ms * (size_t)context.sf_len);
srsran_ringbuffer_free(&ring_buffer);
@ -111,7 +111,7 @@ void intra_measure_base::write(cf_t* data, uint32_t nsamples)
int nbytes = (int)(nsamples * sizeof(cf_t));
mutex.lock();
int required_nbytes = (int)(context.meas_len_ms * context.sf_len * sizeof(cf_t));
int required_nbytes = ((int)context.meas_len_ms * (int)context.sf_len * (int)sizeof(cf_t));
mutex.unlock();
// As nbytes might not match the sub-frame size, make sure that buffer does not overflow
@ -169,8 +169,10 @@ void intra_measure_base::measure_proc()
measure_context_t context_copy = get_context();
// Read data from buffer and find cells in it
int ret = srsran_ringbuffer_read_timed(
&ring_buffer, search_buffer.data(), (int)(context_copy.meas_len_ms * context_copy.sf_len * sizeof(cf_t)), 1000);
int ret = srsran_ringbuffer_read_timed(&ring_buffer,
search_buffer.data(),
((int)context_copy.meas_len_ms * (int)context_copy.sf_len * (int)sizeof(cf_t)),
1000);
// As this function is called once the ring-buffer has enough data to process, it is not expected to fail
if (ret < SRSRAN_SUCCESS) {

@ -95,7 +95,7 @@ bool intra_measure_nr::measure_rat(const measure_context_t context, std::vector<
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
perf_count_us += std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count();
perf_count_samples += context.sf_len * context.meas_len_ms;
perf_count_samples += (uint64_t)context.sf_len * (uint64_t)context.meas_len_ms;
// Early return if the found PCI matches with the serving cell ID
if (serving_cell_pci == (int)N_id) {

@ -68,7 +68,7 @@ class dummy_pdcp : public pdcp_interface_rrc
void reestablish(uint32_t lcid){};
void reset(){};
void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1){};
int add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) { return SRSRAN_SUCCESS; };
int add_bearer(uint32_t lcid, const srsran::pdcp_config_t& cnfg) { return SRSRAN_SUCCESS; };
void del_bearer(uint32_t lcid){};
void change_lcid(uint32_t old_lcid, uint32_t new_lcid){};
void config_security(uint32_t lcid, const srsran::as_security_config_t& sec_cfg){};

@ -261,7 +261,12 @@ void ue_stack_lte::stop_impl()
bool ue_stack_lte::switch_on()
{
if (running) {
ue_task_queue.try_push([this]() { nas.switch_on(); });
stack_logger.info("Triggering NAS switch on\n");
if (!ue_task_queue.try_push([this]() { nas.switch_on(); })) {
stack_logger.error("Triggering NAS switch on: ue_task_queue is full\n");
}
} else {
stack_logger.error("Triggering NAS switch on: stack is not running\n");
}
return true;
}

Loading…
Cancel
Save