Commit b432e4ce authored by mir's avatar mir

Scan build: Result of operation is garbage or undefined

parent 82597e7e
...@@ -137,10 +137,6 @@ void nr_est_delay(int ofdm_symbol_size, const c16_t *ls_est, c16_t *ch_estimates ...@@ -137,10 +137,6 @@ void nr_est_delay(int ofdm_symbol_size, const c16_t *ls_est, c16_t *ch_estimates
#define CEILIDIV(a,b) ((a+b-1)/b) #define CEILIDIV(a,b) ((a+b-1)/b)
#define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1)) #define ROUNDIDIV(a,b) (((a<<1)+b)/(b<<1))
#define cmax(a,b) ((a>b) ? (a) : (b))
#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c))
#define cmin(a,b) ((a<b) ? (a) : (b))
#ifdef __cplusplus #ifdef __cplusplus
#ifdef min #ifdef min
#undef min #undef min
......
...@@ -19,9 +19,21 @@ extern "C" { ...@@ -19,9 +19,21 @@ extern "C" {
#define sizeofArray(a) (sizeof(a)/sizeof(*(a))) #define sizeofArray(a) (sizeof(a)/sizeof(*(a)))
#define cmax(a,b) ((a>b) ? (a) : (b)) // Prevent double evaluation in max macro
#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) #define cmax(a,b) ({ __typeof__ (a) _a = (a); \
#define cmin(a,b) ((a<b) ? (a) : (b)) __typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define cmax3(a,b,c) ( cmax(cmax(a,b), cmax(b,c)) )
// Prevent double evaluation in min macro
#define cmin(a,b) ({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
#ifdef __cplusplus #ifdef __cplusplus
#ifdef min #ifdef min
......
...@@ -194,6 +194,7 @@ int ldpc_encoder_orig(uint8_t *test_input,uint8_t *channel_input,int Zc,int Kb,s ...@@ -194,6 +194,7 @@ int ldpc_encoder_orig(uint8_t *test_input,uint8_t *channel_input,int Zc,int Kb,s
channel_temp=0; channel_temp=0;
fprintf(fd,"\n//row: %d\n",i1); fprintf(fd,"\n//row: %d\n",i1);
fprintf(fd2,"\n//row: %d\n",i1); fprintf(fd2,"\n//row: %d\n",i1);
AssertFatal(shift > 0 , "The result of the right shift is undefined because the right operand is negative\n");
fprintf(fd," d2[%d]=",(Zc*i1)>>shift); fprintf(fd," d2[%d]=",(Zc*i1)>>shift);
fprintf(fd2," d2[%d]=",(Zc*i1)>>(shift-1)); fprintf(fd2," d2[%d]=",(Zc*i1)>>(shift-1));
......
...@@ -116,6 +116,7 @@ int8_t polar_decoder(double *input, ...@@ -116,6 +116,7 @@ int8_t polar_decoder(double *input,
} }
//The index of the last 1-valued bit that appears in each column. //The index of the last 1-valued bit that appears in each column.
AssertFatal(polarParams->crcParityBits > 0, "UB for VLA");
uint16_t last1ind[polarParams->crcParityBits]; uint16_t last1ind[polarParams->crcParityBits];
for (int j=0; j<polarParams->crcParityBits; j++) { for (int j=0; j<polarParams->crcParityBits; j++) {
......
...@@ -257,8 +257,8 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -257,8 +257,8 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
uint8_t n_PC, uint8_t n_PC,
uint8_t n_pc_wm) uint8_t n_pc_wm)
{ {
int16_t *Q_Ftmp_N = malloc(sizeof(int16_t) * (N + 1)); // Last element shows the final int16_t Q_Ftmp_N[N+1]; // Last element shows the final
int16_t *Q_Itmp_N = malloc(sizeof(int16_t) * (N + 1)); // array index assigned a value. int16_t Q_Itmp_N[N+1]; // array index assigned a value.
for (int i = 0; i <= N; i++) { for (int i = 0; i <= N; i++) {
Q_Ftmp_N[i] = -1; // Empty array. Q_Ftmp_N[i] = -1; // Empty array.
...@@ -304,6 +304,7 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -304,6 +304,7 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
for (int n = 0; n <= N - 1; n++) { for (int n = 0; n <= N - 1; n++) {
flag = 1; flag = 1;
for (int m = 0; m <= Q_Ftmp_N[N]; m++) { for (int m = 0; m <= Q_Ftmp_N[N]; m++) {
AssertFatal(m < N+1, "Buffer boundary overflow");
if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) { if (Q_0_Nminus1[n] == Q_Ftmp_N[m]) {
flag = 0; flag = 0;
break; break;
...@@ -364,8 +365,6 @@ void nr_polar_info_bit_pattern(uint8_t *ibp, ...@@ -364,8 +365,6 @@ void nr_polar_info_bit_pattern(uint8_t *ibp,
} }
free(Q_Ftmp_N);
free(Q_Itmp_N);
} }
......
...@@ -292,6 +292,7 @@ void phy_viterbi_dot11_sse2(char *y,unsigned char *decoded_bytes,unsigned short ...@@ -292,6 +292,7 @@ void phy_viterbi_dot11_sse2(char *y,unsigned char *decoded_bytes,unsigned short
// Traceback // Traceback
if (traceback == 1) { if (traceback == 1) {
prev_state0 = 0; prev_state0 = 0;
AssertFatal((offset+n-1) > 0, "Left shift is undefined if the left operand is negative\n");
TB_ptr2 = (unsigned char *)&TB[(offset+n-1)<<2]; TB_ptr2 = (unsigned char *)&TB[(offset+n-1)<<2];
for (position = offset+n-1 ; position>-1; position--) { for (position = offset+n-1 ; position>-1; position--) {
......
...@@ -171,6 +171,8 @@ void rx_prach0(PHY_VARS_eNB *eNB, ...@@ -171,6 +171,8 @@ void rx_prach0(PHY_VARS_eNB *eNB,
AssertFatal(ru!=NULL,"ru is null\n"); AssertFatal(ru!=NULL,"ru is null\n");
int8_t dBEn0=0; int8_t dBEn0=0;
int16_t *prach[nb_rx]; int16_t *prach[nb_rx];
memset(prach, 0, nb_rx * sizeof(int16_t));
for (int aa=0; aa<nb_rx; aa++) { for (int aa=0; aa<nb_rx; aa++) {
if (ru->if_south == LOCAL_RF || ru->function == NGFI_RAU_IF5) { // set the time-domain signal if we have to use it in this node if (ru->if_south == LOCAL_RF || ru->function == NGFI_RAU_IF5) { // set the time-domain signal if we have to use it in this node
// DJP - indexing below in subframe zero takes us off the beginning of the array??? // DJP - indexing below in subframe zero takes us off the beginning of the array???
......
...@@ -756,9 +756,9 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB, ...@@ -756,9 +756,9 @@ uint32_t calc_pucch_1x_interference(PHY_VARS_eNB *eNB,
LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms;
uint32_t u,v,n,aa; uint32_t u,v,n,aa;
uint32_t z[12*14]; uint32_t z[12*14] = {0};
int16_t *zptr; int16_t *zptr = NULL;
int16_t rxcomp[NB_ANTENNAS_RX][2*12*14]; int16_t rxcomp[NB_ANTENNAS_RX][2*12*14] = {0};
uint8_t ns,N_UL_symb,nsymb,n_cs_base; uint8_t ns,N_UL_symb,nsymb,n_cs_base;
uint16_t i,j,re_offset; uint16_t i,j,re_offset;
uint8_t m,l; uint8_t m,l;
......
...@@ -5188,7 +5188,7 @@ double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe) ...@@ -5188,7 +5188,7 @@ double sinr_eff_cqi_calc(PHY_VARS_UE *ue, uint8_t eNB_id, uint8_t subframe)
sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg, sinr_eff_qam64 = (p_qam64[0]*pow(I_qam64_avg,7) + p_qam64[1]*pow(I_qam64_avg,6) + p_qam64[2]*pow(I_qam64_avg,5) + p_qam64[3]*pow(I_qam64_avg,4) + p_qam64[4]*pow(I_qam64_avg,
3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]); 3) + p_qam64[5]*pow(I_qam64_avg,2) + p_qam64[6]*I_qam64_avg + p_qam64[7]);
sinr_eff = cmax3(sinr_eff_qpsk,sinr_eff_qam16,sinr_eff_qam64); sinr_eff = cmax3(sinr_eff_qpsk, sinr_eff_qam16,sinr_eff_qam64);
//printf("SINR_Eff = %e\n",sinr_eff); //printf("SINR_Eff = %e\n",sinr_eff);
......
...@@ -636,10 +636,21 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, ...@@ -636,10 +636,21 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB,
c16_t srs_ls_estimated_channel[frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)]; c16_t srs_ls_estimated_channel[frame_parms->ofdm_symbol_size*(1<<srs_pdu->num_symbols)];
uint32_t noise_power_per_rb[srs_pdu->bwp_size]; uint32_t noise_power_per_rb[srs_pdu->bwp_size];
int16_t ch_real[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS];
int16_t ch_imag[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; const uint32_t arr_len = frame_parms->nb_antennas_rx * N_ap * M_sc_b_SRS;
int16_t noise_real[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS];
int16_t noise_imag[frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS]; int16_t ch_real[arr_len];
memset(ch_real, 0, arr_len * sizeof(int16_t));
int16_t ch_imag[arr_len];
memset(ch_imag, 0, arr_len * sizeof(int16_t));
int16_t noise_real[arr_len];
memset(noise_real, 0, arr_len * sizeof(int16_t));
int16_t noise_imag[arr_len];
memset(noise_imag, 0, arr_len * sizeof(int16_t));
int16_t ls_estimated[2]; int16_t ls_estimated[2];
uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t) uint8_t mem_offset = ((16 - ((long)&srs_estimated_channel_freq[0][0][subcarrier_offset + nr_srs_info->k_0_p[0][0]])) & 0xF) >> 2; // >> 2 <=> /sizeof(int32_t)
...@@ -838,8 +849,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, ...@@ -838,8 +849,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB,
} // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++) } // for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
// Compute signal power // Compute signal power
uint32_t signal_power = calc_power(ch_real,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS) uint32_t signal_power = calc_power(ch_real, arr_len) + calc_power(ch_imag, arr_len);
+ calc_power(ch_imag,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS);
#ifdef SRS_DEBUG #ifdef SRS_DEBUG
LOG_I(NR_PHY,"signal_power = %u\n", signal_power); LOG_I(NR_PHY,"signal_power = %u\n", signal_power);
...@@ -892,8 +902,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB, ...@@ -892,8 +902,7 @@ int nr_srs_channel_estimation(const PHY_VARS_gNB *gNB,
} // for (int rb = 0; rb < m_SRS_b; rb++) } // for (int rb = 0; rb < m_SRS_b; rb++)
uint32_t noise_power = max(calc_power(noise_real,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS) const uint32_t noise_power = max(calc_power(noise_real, arr_len) + calc_power(noise_imag, arr_len), 1);
+ calc_power(noise_imag,frame_parms->nb_antennas_rx*N_ap*M_sc_b_SRS), 1);
*snr = dB_fixed((int32_t)((signal_power<<factor_bits)/(noise_power))) - factor_dB; *snr = dB_fixed((int32_t)((signal_power<<factor_bits)/(noise_power))) - factor_dB;
......
...@@ -1178,7 +1178,8 @@ static uint8_t nr_ulsch_mmse_2layers(NR_DL_FRAME_PARMS *frame_parms, ...@@ -1178,7 +1178,8 @@ static uint8_t nr_ulsch_mmse_2layers(NR_DL_FRAME_PARMS *frame_parms,
int sum_det = 0; int sum_det = 0;
for (int k = 0; k < 4; k++) { for (int k = 0; k < 4; k++) {
sum_det += ((((int *)&determ_fin_128[0])[k]) >> 2); AssertFatal(((int *)&determ_fin_128[0])[k] > 0 ,"Right shifting negative values is UB" );
sum_det += ((((uint32_t *)&determ_fin_128[0])[k]) >> 2);
} }
int b = log2_approx(sum_det) - 8; int b = log2_approx(sum_det) - 8;
......
...@@ -248,6 +248,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB, ...@@ -248,6 +248,8 @@ void nr_decode_pucch0(PHY_VARS_gNB *gNB,
x_im[1] = table_5_2_2_2_2_Im[u[1]]; x_im[1] = table_5_2_2_2_2_Im[u[1]];
c64_t xr[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][12] __attribute__((aligned(32))); c64_t xr[frame_parms->nb_antennas_rx][pucch_pdu->nr_of_symbols][12] __attribute__((aligned(32)));
memset(xr, 0, frame_parms->nb_antennas_rx * pucch_pdu->nr_of_symbols * 12);
int64_t xrtmag=0,xrtmag_next=0; int64_t xrtmag=0,xrtmag_next=0;
uint8_t maxpos=0; uint8_t maxpos=0;
uint8_t index=0; uint8_t index=0;
......
...@@ -74,9 +74,10 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, ...@@ -74,9 +74,10 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
} }
// filter position to reduce jitter // filter position to reduce jitter
if (clear == 1) if (clear == 1){
AssertFatal(max_pos > -1, "The result of the left shift is undefined if the left operand is negative");
ue->max_pos_fil = max_pos << 15; ue->max_pos_fil = max_pos << 15;
else } else
ue->max_pos_fil = ((ue->max_pos_fil * coef) >> 15) + (max_pos * ncoef); ue->max_pos_fil = ((ue->max_pos_fil * coef) >> 15) + (max_pos * ncoef);
// do not filter to have proactive timing adjustment // do not filter to have proactive timing adjustment
......
...@@ -129,6 +129,8 @@ int nr_prs_channel_estimation(uint8_t gNB_id, ...@@ -129,6 +129,8 @@ int nr_prs_channel_estimation(uint8_t gNB_id,
printf("[gNB %d][rsc %d] PRS config l %d k_prime %d:\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", gNB_id, rsc_id, l, k_prime, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize); printf("[gNB %d][rsc %d] PRS config l %d k_prime %d:\nprs_cfg->SymbolStart %d\nprs_cfg->NumPRSSymbols %d\nprs_cfg->NumRB %d\nprs_cfg->CombSize %d\n", gNB_id, rsc_id, l, k_prime, prs_cfg->SymbolStart, prs_cfg->NumPRSSymbols, prs_cfg->NumRB, prs_cfg->CombSize);
#endif #endif
// Pilots generation and modulation // Pilots generation and modulation
AssertFatal(num_pilots > 0, "num_pilots needs to be gt 0 or mod_prs[0] UB");
for (int m = 0; m < num_pilots; m++) for (int m = 0; m < num_pilots; m++)
{ {
idx = (((nr_gold_prs[l][(m<<1)>>5])>>((m<<1)&0x1f))&3); idx = (((nr_gold_prs[l][(m<<1)>>5])>>((m<<1)&0x1f))&3);
......
...@@ -510,6 +510,8 @@ void cic_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, in ...@@ -510,6 +510,8 @@ void cic_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, in
void fir_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int scaling_factor) void fir_decimator(int16_t *input_buffer, int16_t *output_buffer, int length, int rate_change, int scaling_factor)
{ {
AssertFatal(length > 0, "Precondition not met");
int32_t *buffer_one; int32_t *buffer_one;
int32_t *buffer_two; int32_t *buffer_two;
int32_t *input; int32_t *input;
......
...@@ -409,6 +409,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue, ...@@ -409,6 +409,7 @@ int nr_csi_rs_channel_estimation(const PHY_VARS_NR_UE *ue,
} }
/// Power noise estimation /// Power noise estimation
AssertFatal(csirs_config_pdu->nr_of_rbs > 0, " nr_of_rbs needs to be greater than 0\n");
uint16_t noise_real[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs]; uint16_t noise_real[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs];
uint16_t noise_imag[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs]; uint16_t noise_imag[frame_parms->nb_antennas_rx][N_ports][csirs_config_pdu->nr_of_rbs];
for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) { for (int rb = csirs_config_pdu->start_rb; rb < (csirs_config_pdu->start_rb+csirs_config_pdu->nr_of_rbs); rb++) {
......
...@@ -271,7 +271,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, ...@@ -271,7 +271,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
int nr_slot_rx = proc->nr_slot_rx; int nr_slot_rx = proc->nr_slot_rx;
int gNB_id = proc->gNB_id; int gNB_id = proc->gNB_id;
int avg[16]; int avg[16] = {0};
// int avg_0[2]; // int avg_0[2];
// int avg_1[2]; // int avg_1[2];
...@@ -467,7 +467,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue, ...@@ -467,7 +467,7 @@ int nr_rx_pdsch(PHY_VARS_NR_UE *ue,
for (aatx=0;aatx<nl;aatx++) for (aatx=0;aatx<nl;aatx++)
for (aarx=0;aarx<n_rx;aarx++) { for (aarx=0;aarx<n_rx;aarx++) {
//LOG_I(PHY, "nb_rb %d len %d avg_%d_%d Power per SC is %d\n",nb_rb, len,aarx, aatx,avg[aatx*n_rx+aarx]); //LOG_I(PHY, "nb_rb %d len %d avg_%d_%d Power per SC is %d\n",nb_rb, len,aarx, aatx,avg[aatx*n_rx+aarx]);
avgs = cmax(avgs,avg[(aatx*n_rx)+aarx]); avgs = cmax(avgs, avg[(aatx * n_rx) + aarx]);
//LOG_I(PHY, "avgs Power per SC is %d\n", avgs); //LOG_I(PHY, "avgs Power per SC is %d\n", avgs);
median[(aatx*n_rx)+aarx] = avg[(aatx*n_rx)+aarx]; median[(aatx*n_rx)+aarx] = avg[(aatx*n_rx)+aarx];
} }
...@@ -752,7 +752,7 @@ void nr_dlsch_deinterleaving(uint8_t symbol, ...@@ -752,7 +752,7 @@ void nr_dlsch_deinterleaving(uint8_t symbol,
N_bundle = nb_rb_pdsch/L; N_bundle = nb_rb_pdsch/L;
C=N_bundle/R; C=N_bundle/R;
uint32_t *bundle_deint = malloc(N_bundle*sizeof(uint32_t)); uint32_t *bundle_deint = calloc(N_bundle, sizeof(uint32_t));
printf("N_bundle %u L %d nb_rb_pdsch %d\n",N_bundle, L,nb_rb_pdsch); printf("N_bundle %u L %d nb_rb_pdsch %d\n",N_bundle, L,nb_rb_pdsch);
......
...@@ -929,7 +929,9 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue, ...@@ -929,7 +929,9 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
* n_id = {0,1,...,1023} equals the higher-layer parameter Data-scrambling-Identity if configured * 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 * n_id = N_ID_cell if higher layer parameter not configured
*/ */
uint8_t *btilde = malloc(sizeof(int8_t)*M_bit); uint8_t btilde[M_bit];
memset(btilde, 0, M_bit * sizeof(int8_t));
// rnti is given by the C-RNTI // rnti is given by the C-RNTI
uint16_t rnti=pucch_pdu->rnti, n_id=0; uint16_t rnti=pucch_pdu->rnti, n_id=0;
#ifdef DEBUG_NR_PUCCH_TX #ifdef DEBUG_NR_PUCCH_TX
...@@ -946,8 +948,8 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue, ...@@ -946,8 +948,8 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
* Subclause 5.1.3 QPSK * Subclause 5.1.3 QPSK
*/ */
// complex-valued symbol d(0) // complex-valued symbol d(0)
int16_t *d_re = malloc(sizeof(int16_t)*M_bit); int16_t *d_re = calloc(M_bit, sizeof(int16_t));
int16_t *d_im = malloc(sizeof(int16_t)*M_bit); 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; uint16_t m_symbol = (M_bit%2==0) ? M_bit/2 : floor(M_bit/2)+1;
if (is_pi_over_2_bpsk_enabled == 0) { if (is_pi_over_2_bpsk_enabled == 0) {
...@@ -1020,8 +1022,8 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue, ...@@ -1020,8 +1022,8 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
// number of symbols, provided by higher layers parameters PUCCH-F0-F2-number-of-symbols or PUCCH-F1-F3-F4-number-of-symbols // number of symbols, provided by higher layers parameters PUCCH-F0-F2-number-of-symbols or PUCCH-F1-F3-F4-number-of-symbols
// uint8_t nrofSymbols; // uint8_t nrofSymbols;
// complex-valued symbol d(0) // complex-valued symbol d(0)
int16_t *y_n_re = malloc(sizeof(int16_t)*4*M_bit); // 4 is the maximum number n_SF_PUCCH_s, so is the maximunm size of y_n int16_t *y_n_re = calloc(4*M_bit, sizeof(int16_t)); // 4 is the maximum number n_SF_PUCCH_s, so is the maximunm size of y_n
int16_t *y_n_im = malloc(sizeof(int16_t)*4*M_bit); int16_t *y_n_im = calloc(4*M_bit, sizeof(int16_t));
// Re part orthogonal sequences w_n(k) for PUCCH format 4 when N_SF_PUCCH4 = 2 (Table 6.3.2.6.3-1) // Re part orthogonal sequences w_n(k) for PUCCH format 4 when N_SF_PUCCH4 = 2 (Table 6.3.2.6.3-1)
// k={0,..11} n={0,1,2,3} // k={0,..11} n={0,1,2,3}
// parameter PUCCH-F4-preDFT-OCC-index set of {0,1,2,3} -> n // parameter PUCCH-F4-preDFT-OCC-index set of {0,1,2,3} -> n
...@@ -1102,8 +1104,12 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue, ...@@ -1102,8 +1104,12 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
/* /*
* Implementing Transform pre-coding subclause 6.3.2.6.4 * Implementing Transform pre-coding subclause 6.3.2.6.4
*/ */
int16_t *z_re = malloc(sizeof(int16_t)*4*M_bit); // 4 is the maximum number n_SF_PUCCH_s
int16_t *z_im = malloc(sizeof(int16_t)*4*M_bit); int16_t z_re[4*M_bit]; // 4 is the maximum number n_SF_PUCCH_s
memset(z_re, 0, 4*M_bit*sizeof(int16_t));
int16_t z_im[4*M_bit];
memset(z_im, 0, 4*M_bit*sizeof(int16_t));
#define M_PI 3.14159265358979323846 // pi #define M_PI 3.14159265358979323846 // pi
//int16_t inv_sqrt_nrofPRBs = (int16_t)round(32767/sqrt(12*nrofPRB)); //int16_t inv_sqrt_nrofPRBs = (int16_t)round(32767/sqrt(12*nrofPRB));
...@@ -1334,7 +1340,4 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue, ...@@ -1334,7 +1340,4 @@ void nr_generate_pucch3_4(const PHY_VARS_NR_UE *ue,
if (table_6_4_1_3_3_2_1_dmrs_positions[nrofSymbols-4][l] == 1) j+=12; if (table_6_4_1_3_3_2_1_dmrs_positions[nrofSymbols-4][l] == 1) j+=12;
} }
} }
free(z_re);
free(z_im);
free(btilde);
} }
...@@ -267,6 +267,7 @@ static int do_pss_sss_extract_nr( ...@@ -267,6 +267,7 @@ static int do_pss_sss_extract_nr(
c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) // add flag to indicate extracting only PSS, only SSS, or both c16_t rxdataF[][ue->frame_parms.samples_per_slot_wCP]) // add flag to indicate extracting only PSS, only SSS, or both
{ {
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
AssertFatal(frame_parms->nb_antennas_rx > 0, "UB as sss_ext is not set to any value\n");
for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) { for (int aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
int pss_symbol = 0; int pss_symbol = 0;
...@@ -370,7 +371,9 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue, ...@@ -370,7 +371,9 @@ bool rx_sss_nr(PHY_VARS_NR_UE *ue,
{ {
uint8_t i; uint8_t i;
c16_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR]; c16_t pss_ext[NB_ANTENNAS_RX][LENGTH_PSS_NR];
memset(pss_ext, 0, NB_ANTENNAS_RX * LENGTH_SSS_NR * sizeof(c16_t));
c16_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR]; c16_t sss_ext[NB_ANTENNAS_RX][LENGTH_SSS_NR];
memset(sss_ext, 0, NB_ANTENNAS_RX * LENGTH_SSS_NR * sizeof(c16_t));
uint8_t Nid2 = GET_NID2(ue->common_vars.nid2); uint8_t Nid2 = GET_NID2(ue->common_vars.nid2);
uint16_t Nid1; uint16_t Nid1;
uint8_t phase; uint8_t phase;
......
...@@ -86,9 +86,9 @@ ...@@ -86,9 +86,9 @@
#define openair_sched_exit() exit(-1) #define openair_sched_exit() exit(-1)
#define bzero(s,n) (memset((s),0,(n))) #define bzero(s,n) (memset((s),0,(n)))
#define cmax(a,b) ((a>b) ? (a) : (b)) //#define cmax(a,b) ((a>b) ? (a) : (b))
#define cmin(a,b) ((a<b) ? (a) : (b)) //#define cmin(a,b) ((a<b) ? (a) : (b))
#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c)) //#define cmax3(a,b,c) ((cmax(a,b)>c) ? (cmax(a,b)) : (c))
/// suppress compiler warning for unused arguments /// suppress compiler warning for unused arguments
#define UNUSED(x) (void)x; #define UNUSED(x) (void)x;
......
...@@ -94,12 +94,10 @@ double dac_fixed_gain(double *s_re[2], ...@@ -94,12 +94,10 @@ double dac_fixed_gain(double *s_re[2],
int i; int i;
int aa; int aa;
double amp1_local,*amp1p; double amp1_local = 0.0;
double *amp1p = (amp1 == NULL) ? &amp1_local : amp1;
double amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna double amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna
if (amp1==NULL) amp1p = &amp1_local;
else amp1p = amp1;
if (do_amp_compute==1) { if (do_amp_compute==1) {
*amp1p = 0; *amp1p = 0;
for (aa=0; aa<nb_tx_antennas; aa++) { for (aa=0; aa<nb_tx_antennas; aa++) {
...@@ -124,6 +122,7 @@ double dac_fixed_gain(double *s_re[2], ...@@ -124,6 +122,7 @@ double dac_fixed_gain(double *s_re[2],
#endif #endif
AssertFatal(amp1p != NULL && *amp1p != 0.0, "Precondition to avoid UB\n");
for (i=0; i<length; i++) { for (i=0; i<length; i++) {
for (aa=0; aa<nb_tx_antennas; aa++) { for (aa=0; aa<nb_tx_antennas; aa++) {
s_re[aa][i] = amp*((double)(((short *)input[aa]))[((i+input_offset)<<1)])/(*amp1p); s_re[aa][i] = amp*((double)(((short *)input[aa]))[((i+input_offset)<<1)])/(*amp1p);
......
...@@ -195,7 +195,7 @@ void *eNB_app_task(void *args_p) { ...@@ -195,7 +195,7 @@ void *eNB_app_task(void *args_p) {
uint32_t enb_id_end = enb_id_start + enb_nb; uint32_t enb_id_end = enb_id_start + enb_nb;
uint32_t register_enb_pending=0; uint32_t register_enb_pending=0;
uint32_t registered_enb=0; uint32_t registered_enb=0;
long enb_register_retry_timer_id; long enb_register_retry_timer_id = 0;
uint32_t x2_register_enb_pending = 0; uint32_t x2_register_enb_pending = 0;
uint32_t x2_registered_enb = 0; uint32_t x2_registered_enb = 0;
long x2_enb_register_retry_timer_id; long x2_enb_register_retry_timer_id;
......
...@@ -1648,7 +1648,6 @@ schedule_ue_spec_fairRR(module_id_t module_idP, ...@@ -1648,7 +1648,6 @@ schedule_ue_spec_fairRR(module_id_t module_idP,
header_len_dcch += 2; header_len_dcch += 2;
UE_info->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1; UE_info->eNB_UE_stats[CC_id][UE_id].num_pdu_tx[DCCH1] += 1;
UE_info->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus]; UE_info->eNB_UE_stats[CC_id][UE_id].num_bytes_tx[DCCH1] += sdu_lengths[num_sdus];
num_sdus++;
#ifdef DEBUG_eNB_SCHEDULER #ifdef DEBUG_eNB_SCHEDULER
LOG_T(MAC, LOG_T(MAC,
"[eNB %d][DCCH1] CC_id %d Got %d bytes :", "[eNB %d][DCCH1] CC_id %d Got %d bytes :",
...@@ -1660,6 +1659,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP, ...@@ -1660,6 +1659,7 @@ schedule_ue_spec_fairRR(module_id_t module_idP,
LOG_T(MAC, "\n"); LOG_T(MAC, "\n");
#endif #endif
num_sdus++;
} }
} }
......
...@@ -4539,7 +4539,8 @@ extract_pucch_csi(module_id_t mod_idP, ...@@ -4539,7 +4539,8 @@ extract_pucch_csi(module_id_t mod_idP,
AssertFatal(cqi_ReportPeriodic->present != LTE_CQI_ReportPeriodic_PR_NOTHING, "cqi_ReportPeriodic->present == LTE_CQI_ReportPeriodic_PR_NOTHING!\n"); AssertFatal(cqi_ReportPeriodic->present != LTE_CQI_ReportPeriodic_PR_NOTHING, "cqi_ReportPeriodic->present == LTE_CQI_ReportPeriodic_PR_NOTHING!\n");
AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING, AssertFatal(cqi_ReportPeriodic->choice.setup.cqi_FormatIndicatorPeriodic.present != LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING,
"cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n"); "cqi_ReportPeriodic->cqi_FormatIndicatorPeriodic.choice.setup.present == LTE_CQI_ReportPeriodic__setup__cqi_FormatIndicatorPeriodic_PR_NOTHING!\n");
uint16_t Npd, N_OFFSET_CQI; uint16_t Npd = 0;
uint16_t N_OFFSET_CQI = 0;
int H, K, bandwidth_part, L, Lmask; int H, K, bandwidth_part, L, Lmask;
int ri = sched_ctl->periodic_ri_received[CC_idP]; int ri = sched_ctl->periodic_ri_received[CC_idP];
get_csi_params(cc, get_csi_params(cc,
......
...@@ -186,6 +186,7 @@ void nr_srs_ri_computation(const nfapi_nr_srs_normalized_channel_iq_matrix_t *nr ...@@ -186,6 +186,7 @@ void nr_srs_ri_computation(const nfapi_nr_srs_normalized_channel_iq_matrix_t *nr
if ((row == 2 && col == 2) || (row == 4 && col == 2)) { if ((row == 2 && col == 2) || (row == 4 && col == 2)) {
int array_lim = num_prgs >> 2; int array_lim = num_prgs >> 2;
AssertFatal(array_lim > 0 , "Needed to avoid UB\n");
int antenna_rank[array_lim]; int antenna_rank[array_lim];
int count = 0; int count = 0;
......
...@@ -315,7 +315,7 @@ void *MCE_app_task(void *args_p) { ...@@ -315,7 +315,7 @@ void *MCE_app_task(void *args_p) {
uint32_t register_mce_pending=0; uint32_t register_mce_pending=0;
uint32_t registered_mce=0; uint32_t registered_mce=0;
//long mce_register_retry_timer_id; //long mce_register_retry_timer_id;
long mce_scheduling_info_timer_id; long mce_scheduling_info_timer_id = 0;
//uint32_t m3_register_mce_pending = 0; //uint32_t m3_register_mce_pending = 0;
// uint32_t x2_registered_mce = 0; // uint32_t x2_registered_mce = 0;
// long x2_mce_register_retry_timer_id; // long x2_mce_register_retry_timer_id;
......
...@@ -751,7 +751,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request, ...@@ -751,7 +751,7 @@ void check_and_process_dci(nfapi_nr_dl_tti_request_t *dl_tti_request,
.frame_rx = frame, .frame_rx = frame,
.slot_rx = slot, .slot_rx = slot,
.slot_tx = (slot + slot_ahead) % slots_per_frame, .slot_tx = (slot + slot_ahead) % slots_per_frame,
.frame_tx = (ul_info.slot_rx + slot_ahead >= slots_per_frame) ? ul_info.frame_rx + 1 : ul_info.frame_rx}; .frame_tx = (slot + slot_ahead >= slots_per_frame) ? frame + 1 : frame};
nr_ue_ul_scheduler(&ul_info); nr_ue_ul_scheduler(&ul_info);
} }
} }
......
...@@ -679,7 +679,7 @@ int emm_proc_plmn_selection_end(nas_user_t *user, int found, tac_t tac, ci_t ci, ...@@ -679,7 +679,7 @@ int emm_proc_plmn_selection_end(nas_user_t *user, int found, tac_t tac, ci_t ci,
{ {
LOG_FUNC_IN; LOG_FUNC_IN;
emm_sap_t emm_sap; emm_sap_t emm_sap = {0};
int rc = RETURNerror; int rc = RETURNerror;
emm_data_t *emm_data = user->emm_data; emm_data_t *emm_data = user->emm_data;
emm_plmn_list_t *emm_plmn_list = user->emm_plmn_list; emm_plmn_list_t *emm_plmn_list = user->emm_plmn_list;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment