1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-06-24 05:53:16 +00:00

fixing coverity issues

This commit is contained in:
Carles Fernandez 2015-05-13 16:40:46 +02:00
parent 63e7cf810c
commit d1a1815083
14 changed files with 96 additions and 34 deletions

View File

@ -381,7 +381,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items,
magt = d_magnitude_folded[indext] / (fft_normalization_factor * fft_normalization_factor);
delete d_signal_folded;
delete[] d_signal_folded;
// 4- record the maximum peak and the associated synchronization parameters
if (d_mag < magt)

View File

@ -550,6 +550,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_in
*d_Prompt = gr_complex(0,0);
*d_Late = gr_complex(0,0);
current_synchro_data.System = {'G'};
current_synchro_data.Flag_valid_pseudorange = false;
*out[0] = current_synchro_data;
}

View File

@ -32,5 +32,19 @@
#include "gps_almanac.h"
Gps_Almanac::Gps_Almanac() {}
Gps_Almanac::Gps_Almanac()
{
i_satellite_PRN = 0;
d_Delta_i = 0.0;
d_Toa = 0.0;
d_M_0 = 0.0;
d_e_eccentricity = 0.0;
d_sqrt_A = 0.0;
d_OMEGA0 = 0.0;
d_OMEGA = 0.0;
d_OMEGA_DOT = 0.0;
i_SV_health = 0;
d_A_f0 = 0.0;
d_A_f1 = 0.0;
}

View File

@ -114,21 +114,30 @@ Gps_Ephemeris::Gps_Ephemeris()
satelliteBlock[13] = "IIR";
satelliteBlock[23] = "IIR";
satelliteBlock[26] = "IIA";
d_satClkDrift = 0.0;
d_dtr = 0.0;
d_satpos_X = 0.0;
d_satpos_Y = 0.0;
d_satpos_Z = 0.0;
d_satvel_X = 0.0;
d_satvel_Y = 0.0;
d_satvel_Z = 0.0;
}
double Gps_Ephemeris::check_t(double time)
{
double corrTime;
double half_week = 302400; // seconds
double half_week = 302400.0; // seconds
corrTime = time;
if (time > half_week)
{
corrTime = time - 2*half_week;
corrTime = time - 2.0 * half_week;
}
else if (time < -half_week)
{
corrTime = time + 2*half_week;
corrTime = time + 2.0 * half_week;
}
return corrTime;
}
@ -157,30 +166,30 @@ double Gps_Ephemeris::sv_clock_relativistic_term(double transmitTime)
double M;
// Restore semi-major axis
a = d_sqrt_A*d_sqrt_A;
a = d_sqrt_A * d_sqrt_A;
// Time from ephemeris reference epoch
tk = check_t(transmitTime - d_Toe);
// Computed mean motion
n0 = sqrt(GM / (a*a*a));
n0 = sqrt(GM / (a * a * a));
// Corrected mean motion
n = n0 + d_Delta_n;
// Mean anomaly
M = d_M_0 + n * tk;
// Reduce mean anomaly to between 0 and 2pi
M = fmod((M + 2*GPS_PI), (2*GPS_PI));
M = fmod((M + 2.0 * GPS_PI), (2.0 * GPS_PI));
// Initial guess of eccentric anomaly
E = M;
// --- Iteratively compute eccentric anomaly ----------------------------
for (int ii = 1; ii<20; ii++)
for (int ii = 1; ii < 20; ii++)
{
E_old = E;
E = M + d_e_eccentricity * sin(E);
dE = fmod(E - E_old, 2*GPS_PI);
dE = fmod(E - E_old, 2.0 * GPS_PI);
if (fabs(dE) < 1e-12)
{
//Necessary precision is reached, exit from the loop

View File

@ -35,6 +35,13 @@
Gps_Iono::Gps_Iono()
{
valid = false;
d_alpha0 = 0.0;
d_alpha1 = 0.0;
d_alpha2 = 0.0;
d_alpha3 = 0.0;
d_beta0 = 0.0;
d_beta1 = 0.0;
d_beta2 = 0.0;
d_beta3 = 0.0;
}

View File

@ -84,6 +84,7 @@ void Gps_Navigation_Message::reset()
//d_master_clock=0;
d_dtr = 0;
d_satClkCorr = 0;
d_satClkDrift = 0;
// satellite positions
d_satpos_X = 0;
@ -787,6 +788,14 @@ Gps_Ephemeris Gps_Navigation_Message::get_ephemeris()
ephemeris.b_integrity_status_flag = b_integrity_status_flag;
ephemeris.b_alert_flag = b_alert_flag;
ephemeris.b_antispoofing_flag = b_antispoofing_flag;
ephemeris.d_satClkDrift = d_satClkDrift;
ephemeris.d_dtr = d_dtr;
ephemeris.d_satpos_X = d_satpos_X;
ephemeris.d_satpos_Y = d_satpos_Y;
ephemeris.d_satpos_Z = d_satpos_Z;
ephemeris.d_satvel_X = d_satvel_X;
ephemeris.d_satvel_Y = d_satvel_Y;
ephemeris.d_satvel_Z = d_satvel_Z;
return ephemeris;
}

View File

@ -150,6 +150,7 @@ public:
//double d_master_clock; // GPS transmission time
double d_satClkCorr; // GPS clock error
double d_dtr; // relativistic clock correction term
double d_satClkDrift;
// satellite positions
double d_satpos_X; //!< Earth-fixed coordinate x of the satellite [m]. Intersection of the IERS Reference Meridian (IRM) and the plane passing through the origin and normal to the Z-axis.

View File

@ -34,5 +34,8 @@
Gps_Ref_Location::Gps_Ref_Location()
{
valid = false;
lat = 0.0;
lon = 0.0;
uncertainty = 0.0;
}

View File

@ -34,5 +34,9 @@
Gps_Ref_Time::Gps_Ref_Time()
{
valid = false;
d_TOW = 0.0;
d_Week = 0.0;
d_tv_sec = 0.0;
d_tv_usec = 0.0;
}

View File

@ -53,12 +53,12 @@ TEST(CodeGenGPSL1_Test, CodeGeneration)
{
gps_l1_ca_code_gen_complex( _dest, _prn, _chip_shift);
}
delete[] _dest;
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
ASSERT_LE(0, end - begin);
std::cout << "Generation completed in " << (end - begin) << " microseconds" << std::endl;
delete[] _dest;
/* std::complex<float>* _dest2 = new std::complex<float>[1023];gettimeofday(&tv, NULL);
@ -87,10 +87,10 @@ TEST(CodeGenGPSL1Sampled_Test, CodeGeneration)
{
signed int _prn = 1;
unsigned int _chip_shift = 4;
int _fs = 8000000;
double _fs = 8000000;
const signed int _codeFreqBasis = 1023000; //Hz
const signed int _codeLength = 1023;
int _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
int _samplesPerCode = round(_fs / (double)(_codeFreqBasis / _codeLength));
std::complex<float>* _dest = new std::complex<float>[_samplesPerCode];
int iterations = 1000;
@ -106,9 +106,10 @@ TEST(CodeGenGPSL1Sampled_Test, CodeGeneration)
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
delete[] _dest;
ASSERT_LE(0, end - begin);
std::cout << "Generation completed in " << (end - begin) << " microseconds" << std::endl;
delete[] _dest;
/* std::complex<float>* _dest2 = new std::complex<float>[_samplesPerCode];
gettimeofday(&tv, NULL);
@ -137,7 +138,7 @@ TEST(ComplexCarrier_Test, CodeGeneration)
double _f = 4000;
const signed int _codeFreqBasis = 1023000; //Hz
const signed int _codeLength = 1023;
int _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
int _samplesPerCode = round(_fs / (double)(_codeFreqBasis / _codeLength));
std::complex<float>* _dest = new std::complex<float>[_samplesPerCode];
int iterations = 1000;
@ -153,6 +154,7 @@ TEST(ComplexCarrier_Test, CodeGeneration)
gettimeofday(&tv, NULL);
long long int end = tv.tv_sec * 1000000 + tv.tv_usec;
delete[] _dest;
ASSERT_LE(0, end - begin);
std::cout << "Carrier generation completed in " << (end - begin) << " microseconds" << std::endl;
@ -176,5 +178,5 @@ TEST(ComplexCarrier_Test, CodeGeneration)
std::cout << _dest[10] << "and " << _dest2[10] << std::endl;
delete[] _dest2;*/
delete[] _dest;
}

View File

@ -64,15 +64,20 @@ TEST(ComplexCarrier_Test, StandardComplexImplementation)
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier in standard C++ (dynamic allocation) generated in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(1,0);
std::vector<std::complex<float>> mag(FLAGS_size_carrier_test);
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
mag[i] = output[i] * std::conj(output[i]);
}
delete[] output;
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
ASSERT_FLOAT_EQ(std::norm(expected), std::norm(mag[i]));
}
delete [] output;
ASSERT_LE(0, end - begin);
}
@ -127,13 +132,17 @@ TEST(ComplexCarrier_Test, OwnComplexImplementation)
std::cout << "A " << FLAGS_size_carrier_test
<< "-length complex carrier using fixed point generated in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(1,0);
std::vector<std::complex<float>> mag(FLAGS_size_carrier_test);
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
mag[i] = output[i] * std::conj(output[i]);
}
delete[] output;
for(int i = 0; i < FLAGS_size_carrier_test; i++)
{
ASSERT_NEAR(std::norm(expected), std::norm(mag[i]), 0.0001);
}
delete [] output;
ASSERT_LE(0, end - begin);
}

View File

@ -59,9 +59,11 @@ TEST(Conjugate_Test, StandardCComplexImplementation)
std::cout << "Conjugate of a " << FLAGS_size_conjugate_test
<< "-length complex float vector in standard C finished in " << (end - begin)
<< " microseconds" << std::endl;
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
delete [] input;
delete [] output;
}

View File

@ -58,9 +58,9 @@ TEST(MagnitudeSquared_Test, StandardCComplexImplementation)
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector in standard C computed in " << (end - begin)
<< " microseconds" << std::endl;
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
delete [] input;
delete [] output;
}
TEST(MagnitudeSquared_Test, C11ComplexImplementation)
@ -130,9 +130,9 @@ TEST(MagnitudeSquared_Test, VolkComplexImplementation)
std::cout << "The squared magnitude of a " << FLAGS_size_magnitude_test
<< "-length vector using VOLK computed in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
volk_free(input);
volk_free(output);
ASSERT_LE(0, end - begin);
}
// volk_32f_accumulator_s32f(&d_input_power, d_magnitude, d_fft_size);

View File

@ -59,16 +59,17 @@ TEST(Multiply_Test, StandardCDoubleImplementation)
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " doubles in standard C finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
double acc = 0;
double expected = 0;
for(int i = 0; i < FLAGS_size_multiply_test; i++)
{
acc += output[i];
}
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_EQ(expected, acc);
delete [] input;
delete [] output;
}
@ -113,17 +114,17 @@ TEST(Multiply_Test, StandardCComplexImplementation)
std::cout << "Element-wise multiplication of " << FLAGS_size_multiply_test
<< " complex<float> in standard C finished in " << (end - begin)
<< " microseconds" << std::endl;
ASSERT_LE(0, end - begin);
std::complex<float> expected(0,0);
std::complex<float> result(0,0);
for(int i = 0; i < FLAGS_size_multiply_test; i++)
{
result += output[i];
}
delete[] input;
delete[] output;
ASSERT_LE(0, end - begin);
ASSERT_EQ(expected, result);
delete [] input;
delete [] output;
}