From 2ccc58f6d332eee856aec8272cc7439e179098be Mon Sep 17 00:00:00 2001 From: mir Date: Wed, 25 Oct 2023 11:51:33 +0200 Subject: [PATCH] Assigned value is garbage or undefined reportedt by scan-build --- executables/nr-ue.c | 3 ++- .../CODING/nrPolar_tools/nr_polar_procedures.c | 8 ++++---- openair1/PHY/INIT/lte_parms.c | 1 + openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 15 ++++++++------- openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c | 2 +- openair1/PHY/NR_UE_TRANSPORT/csi_rx.c | 4 ++-- openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c | 1 + openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 11 ++++++----- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/executables/nr-ue.c b/executables/nr-ue.c index 64653a280b..8cb2a29d15 100644 --- a/executables/nr-ue.c +++ b/executables/nr-ue.c @@ -743,7 +743,8 @@ void *UE_thread(void *arg) //this thread should be over the processing thread to keep in real time PHY_VARS_NR_UE *UE = (PHY_VARS_NR_UE *) arg; // int tx_enabled = 0; - openair0_timestamp timestamp, writeTimestamp; + openair0_timestamp timestamp = 0; + openair0_timestamp writeTimestamp = 0; void *rxp[NB_ANTENNAS_RX]; int start_rx_stream = 0; fapi_nr_config_request_t *cfg = &UE->nrUE_config; diff --git a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c index 4df7557495..8d7edaf376 100644 --- a/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c +++ b/openair1/PHY/CODING/nrPolar_tools/nr_polar_procedures.c @@ -396,9 +396,9 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, uint16_t E) { uint8_t i; - uint16_t *d, *y, ind; + uint16_t *d, ind; d = (uint16_t *)malloc(sizeof(uint16_t) * N); - y = (uint16_t *)malloc(sizeof(uint16_t) * N); + uint16_t* y = calloc(N, sizeof(uint16_t)); for (int m=0; m<=N-1; m++) d[m]=m; @@ -416,11 +416,11 @@ void nr_polar_rate_matching_pattern(uint16_t *rmp, } else { if ( (K/(double)E) <= (7.0/16) ) { //puncturing for (int k=0; k<=E-1; k++) { - rmp[k]=y[k+N-E]; + rmp[k]=y[k+N-E]; } } else { //shortening for (int k=0; k<=E-1; k++) { - rmp[k]=y[k]; + rmp[k]=y[k]; } } } diff --git a/openair1/PHY/INIT/lte_parms.c b/openair1/PHY/INIT/lte_parms.c index 3fa74edb1a..4601f97b6e 100644 --- a/openair1/PHY/INIT/lte_parms.c +++ b/openair1/PHY/INIT/lte_parms.c @@ -151,6 +151,7 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms, frame_parms->ofdm_symbol_size = 256*osf; frame_parms->samples_per_tti = 3840*osf; frame_parms->first_carrier_offset = frame_parms->ofdm_symbol_size - 90; + AssertFatal(log2_osf < 4 ,"log2_osf %d will cause undefined behaviour \n", log2_osf); frame_parms->nb_prefix_samples>>=(3-log2_osf); frame_parms->nb_prefix_samples0>>=(3-log2_osf); frame_parms->N_RBGS = 2; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 3bc7a32d60..b9d4fbc906 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -1065,8 +1065,8 @@ int allocate_REs_in_RB_pilots_QPSK_tm2(PHY_VARS_eNB* phy_vars_eNB, first_re=6; re=first_re; x0p=&x0[*jj]; - uint64_t tmp0[4]; - uint64_t tmp1[4]; + uint64_t tmp0[4] = {0}; + uint64_t tmp1[4] = {0}; qam4_table_offset=(((uint32_t)x0p[0]))| (((uint32_t)x0p[1])<<1)| @@ -1338,8 +1338,8 @@ int allocate_REs_in_RB_pilots_16QAM_tm2(PHY_VARS_eNB* phy_vars_eNB, first_re=6; re=first_re; x0p=&x0[*jj]; - uint64_t tmp0[4]; - uint64_t tmp1[4]; + uint64_t tmp0[4] = {0}; + uint64_t tmp1[4] = {0}; qam16_table_offset=(((uint32_t)x0p[0])<<1)|(((uint32_t)x0p[2]))| (((uint32_t)x0p[1])<<3)|(((uint32_t)x0p[3])<<2) | @@ -1503,8 +1503,8 @@ int allocate_REs_in_RB_pilots_64QAM_tm2(PHY_VARS_eNB* phy_vars_eNB, x0p=&x0[*jj]; - uint64_t tmp0[4]; - uint64_t tmp1[4]; + uint64_t tmp0[4] = {0}; + uint64_t tmp1[4] = {0}; // 12-bits corresponds to 2 64QAM symbols input which generates 2 64QAM symbols on 2 TX antenna ports qam64_table_offset=(((uint32_t)x0p[0])<<2)|(((uint32_t)x0p[2])<<1)|(((uint32_t)x0p[4]))| @@ -1691,7 +1691,8 @@ int allocate_REs_in_RB(PHY_VARS_eNB* phy_vars_eNB, int16_t re_off=re_offset; uint8_t first_re,last_re; - int32_t tmp_sample1,tmp_sample2; + int32_t tmp_sample1 = 0; + int32_t tmp_sample2 = 0; int16_t tmp_amp=amp; int s=1; int mprime2 = mprime,ind,ind_dword,ind_qpsk_symb; diff --git a/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c index 0cc81d2a29..3317c036d8 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/cic_filter_nr.c @@ -327,7 +327,7 @@ void cic_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, in } /* get working buffers */ - buffer_one = malloc(length*sizeof(int32_t) * 2); /* for i&q samples */ + buffer_one = calloc(length, sizeof(int32_t) * 2); /* for i&q samples */ if (buffer_one == NULL) { msg("Fatal memory allocation problem \n"); assert(0); diff --git a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c index 0ca2371a33..60886ba58d 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c +++ b/openair1/PHY/NR_UE_TRANSPORT/csi_rx.c @@ -904,8 +904,8 @@ void nr_ue_csi_rs_procedures(PHY_VARS_NR_UE *ue, UE_nr_rxtx_proc_t *proc, c16_t uint8_t rank_indicator = 0; uint32_t precoded_sinr_dB = 0; uint8_t cqi = 0; - uint8_t i1[3]; - uint8_t i2[1]; + uint8_t i1[3] = {0}; + uint8_t i2[1] = {0}; nfapi_nr_dl_tti_csi_rs_pdu_rel15_t csi_params = convert_csirs_pdu(csirs_config_pdu); nr_generate_csi_rs(frame_parms, ue->nr_csi_info->csi_rs_generated_signal, diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c index 6ca2f2da5e..e9f3e3282a 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_ulsch_ue.c @@ -292,6 +292,7 @@ void nr_ue_ulsch_procedures(PHY_VARS_NR_UE *UE, /// Transform-coded "y"-sequences (for definition see 38-211 V15.3.0 2018-09, subsection 6.3.1.4) int32_t y[max_num_re] __attribute__ ((aligned(16))); + memset(y, 0, max_num_re*sizeof(int32_t)); if (pusch_pdu->transform_precoding == transformPrecoder_enabled) { diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 728468bc04..b73d432f2e 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -666,9 +666,9 @@ void nr_generate_pucch2(const PHY_VARS_NR_UE *ue, printf("\t [nr_generate_pucch2] start function at slot(nr_slot_tx)=%d with payload=%lu and nr_bit=%d\n",nr_slot_tx, pucch_pdu->payload, pucch_pdu->n_bit); #endif // b is the block of bits transmitted on the physical channel after payload coding - uint64_t b[16]; // limit to 1024-bit encoded length + uint64_t b[16] = {0}; // limit to 1024-bit encoded length // M_bit is the number of bits of block b (payload after encoding) - uint16_t M_bit; + uint16_t M_bit = 0; nr_uci_encoding(pucch_pdu->payload, pucch_pdu->n_bit, 2,0, @@ -687,7 +687,8 @@ void nr_generate_pucch2(const PHY_VARS_NR_UE *ue, * n_id = {0,1,...,1023} equals the higher-layer parameter Data-scrambling-Identity if configured * n_id = N_ID_cell if higher layer parameter not configured */ - uint8_t *btilde = malloc(sizeof(int8_t)*M_bit); + uint8_t *btilde = calloc(M_bit, sizeof(uint8_t)); + // rnti is given by the C-RNTI uint16_t rnti=pucch_pdu->rnti; #ifdef DEBUG_NR_PUCCH_TX @@ -716,8 +717,8 @@ void nr_generate_pucch2(const PHY_VARS_NR_UE *ue, */ //#define ONE_OVER_SQRT2_S 23171 // 32767/sqrt(2) = 23170 (ONE_OVER_SQRT2) // complex-valued symbol d(0) - int16_t *d_re = malloc(sizeof(int16_t)*M_bit); - int16_t *d_im = malloc(sizeof(int16_t)*M_bit); + int16_t *d_re = calloc(M_bit, sizeof(int16_t)); + int16_t *d_im = calloc(M_bit, sizeof(int16_t)); uint16_t m_symbol = (M_bit%2==0) ? M_bit/2 : floor(M_bit/2)+1; for (int i=0; i < m_symbol; i++) { // QPSK modulation subclause 5.1.3