new set of cppcheck fixes

This commit is contained in:
frtabu
2019-02-12 10:12:07 +01:00
parent 63143b87a7
commit 824d2b478a
58 changed files with 13452 additions and 15300 deletions
+12 -38
View File
@@ -32,17 +32,14 @@
// NEW code with lookup table for sin/cos based on delay profile (TO BE TESTED)
double **cos_lut=NULL,**sin_lut=NULL;
double **cos_lut=NULL,* *sin_lut=NULL;
//#if 1
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
{
int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
double delta_f,freq; // 90 kHz spacing
double delay;
int16_t f;
@@ -50,21 +47,18 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
if ((n_samples&1)==0) {
fprintf(stderr, "freq_channel_init: n_samples has to be odd\n");
return(-1);
return(-1);
}
cos_lut = (double **)malloc(n_samples*sizeof(double*));
sin_lut = (double **)malloc(n_samples*sizeof(double*));
cos_lut = (double **)malloc(n_samples*sizeof(double *));
sin_lut = (double **)malloc(n_samples*sizeof(double *));
delta_f = nb_rb*180000/(n_samples-1);
for (f=-(n_samples>>1); f<=(n_samples>>1); f++) {
freq=delta_f*(double)f*1e-6;// due to the fact that delays is in mus
cos_lut[f+(n_samples>>1)] = (double *)malloc((int)desc->nb_taps*sizeof(double));
sin_lut[f+(n_samples>>1)] = (double *)malloc((int)desc->nb_taps*sizeof(double));
for (l=0; l<(int)desc->nb_taps; l++) {
if (desc->nb_taps==1)
delay = desc->delays[l];
@@ -74,17 +68,13 @@ int init_freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
cos_lut[f+(n_samples>>1)][l] = cos(2*M_PI*freq*delay);
sin_lut[f+(n_samples>>1)][l] = sin(2*M_PI*freq*delay);
//printf("values cos:%d, sin:%d\n", cos_lut[f][l], sin_lut[f][l]);
}
}
return(0);
}
int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
{
int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples) {
int16_t f,f2,d;
uint8_t aarx,aatx,l;
double *clut,*slut;
@@ -95,7 +85,7 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
// n_samples has to be a odd number because we assume the spectrum is symmetric around the DC and includes the DC
if ((n_samples&1)==0) {
fprintf(stderr, "freq_channel: n_samples has to be odd\n");
return(-1);
return(-1);
}
// printf("no of taps:%d,",(int)desc->nb_taps);
@@ -104,6 +94,7 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
// we are initializing the lut for the largets possible n_samples=12*nb_rb+1
// if called with n_samples<12*nb_rb+1, we decimate the lut
n_samples_max=12*nb_rb+1;
if (init_freq_channel(desc,nb_rb,n_samples_max)==0)
freq_channel_init=1;
else
@@ -111,9 +102,7 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
}
d=(n_samples_max-1)/(n_samples-1);
//printf("no_samples=%d, n_samples_max=%d, d=%d\n",n_samples,n_samples_max,d);
start_meas(&desc->interp_freq);
for (f=-n_samples_max/2,f2=-n_samples/2; f<n_samples_max/2; f+=d,f2++) {
@@ -126,7 +115,6 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].y=0.0;
for (l=0; l<(int)desc->nb_taps; l++) {
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].x+=(desc->a[l][aarx+(aatx*desc->nb_rx)].x*clut[l]+
desc->a[l][aarx+(aatx*desc->nb_rx)].y*slut[l]);
desc->chF[aarx+(aatx*desc->nb_rx)][n_samples/2+f2].y+=(-desc->a[l][aarx+(aatx*desc->nb_rx)].x*slut[l]+
@@ -137,7 +125,6 @@ int freq_channel(channel_desc_t *desc,uint16_t nb_rb,int16_t n_samples)
}
stop_meas(&desc->interp_freq);
return(0);
}
@@ -146,16 +133,13 @@ double compute_pbch_sinr(channel_desc_t *desc,
channel_desc_t *desc_i2,
double snr_dB,double snr_i1_dB,
double snr_i2_dB,
uint16_t nb_rb)
{
uint16_t nb_rb) {
double avg_sinr,snr=pow(10.0,.1*snr_dB),snr_i1=pow(10.0,.1*snr_i1_dB),snr_i2=pow(10.0,.1*snr_i2_dB);
uint16_t f;
uint8_t aarx,aatx;
double S;
struct complex S_i1;
struct complex S_i2;
avg_sinr=0.0;
// printf("nb_rb %d\n",nb_rb);
@@ -202,18 +186,14 @@ double compute_sinr(channel_desc_t *desc,
channel_desc_t *desc_i2,
double snr_dB,double snr_i1_dB,
double snr_i2_dB,
uint16_t nb_rb)
{
uint16_t nb_rb) {
double avg_sinr,snr=pow(10.0,.1*snr_dB),snr_i1=pow(10.0,.1*snr_i1_dB),snr_i2=pow(10.0,.1*snr_i2_dB);
uint16_t f;
uint8_t aarx,aatx;
double S;
struct complex S_i1;
struct complex S_i2;
DevAssert( nb_rb > 0 );
avg_sinr=0.0;
// printf("nb_rb %d\n",nb_rb);
@@ -256,12 +236,9 @@ double compute_sinr(channel_desc_t *desc,
int pbch_polynomial_degree=6;
double pbch_awgn_polynomial[7]= {-7.2926e-05, -2.8749e-03, -4.5064e-02, -3.5301e-01, -1.4655e+00, -3.6282e+00, -6.6907e+00};
void load_pbch_desc(FILE *pbch_file_fd)
{
void load_pbch_desc(FILE *pbch_file_fd) {
int i, ret;
char dummy[25];
ret = fscanf(pbch_file_fd,"%d",&pbch_polynomial_degree);
if (ret < 0) {
@@ -291,9 +268,7 @@ void load_pbch_desc(FILE *pbch_file_fd)
printf("\n");
}
double pbch_bler(double sinr)
{
double pbch_bler(double sinr) {
int i;
double log10_bler=pbch_awgn_polynomial[pbch_polynomial_degree];
double sinrpow=sinr;
@@ -317,6 +292,5 @@ double pbch_bler(double sinr)
//printf ("sinr %f bler %f\n",sinr,bler);
return(bler);
}