[hamradio-commits] [gnss-sdr] 77/251: fixing coverity issues

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Wed Sep 2 00:22:37 UTC 2015


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch master
in repository gnss-sdr.

commit 76843781f74ff1b88899de05ee6759893094c02b
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Thu May 14 11:20:02 2015 +0200

    fixing coverity issues
---
 src/algorithms/libs/galileo_e5_signal_processing.cc               | 8 ++++----
 .../volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c     | 2 +-
 .../observables/gnuradio_blocks/galileo_e1_observables_cc.cc      | 4 ++--
 .../observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc       | 4 ++--
 .../observables/gnuradio_blocks/hybrid_observables_cc.cc          | 6 +++---
 src/core/system_parameters/sbas_time.h                            | 3 +++
 6 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/algorithms/libs/galileo_e5_signal_processing.cc b/src/algorithms/libs/galileo_e5_signal_processing.cc
index 6ef0729..6b7d202 100644
--- a/src/algorithms/libs/galileo_e5_signal_processing.cc
+++ b/src/algorithms/libs/galileo_e5_signal_processing.cc
@@ -101,14 +101,14 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
     // This function is based on the GNU software GPS for MATLAB in the Kay Borre book
     unsigned int _samplesPerCode;
     unsigned int delay;
-    const unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS;
+    unsigned int _codeLength = Galileo_E5a_CODE_LENGTH_CHIPS;
     const int _codeFreqBasis = Galileo_E5a_CODE_CHIP_RATE_HZ; //Hz
 
     std::complex<float>* _code = new std::complex<float>[_codeLength];
 
     galileo_e5_a_code_gen_complex_primary(_code , _prn , _Signal);
 
-    _samplesPerCode = round(_fs / (_codeFreqBasis / _codeLength));
+    _samplesPerCode = static_cast<unsigned int>(static_cast<double>(_fs) / ( static_cast<double>(_codeFreqBasis) / static_cast<double>(_codeLength)));
 
     delay = ((_codeLength - _chip_shift) % _codeLength) * _samplesPerCode / _codeLength;
 
@@ -117,8 +117,8 @@ void galileo_e5_a_code_gen_complex_sampled(std::complex<float>* _dest, char _Sig
         	std::complex<float>* _resampled_signal;
         	if (posix_memalign((void**)&_resampled_signal, 16, _samplesPerCode * sizeof(gr_complex)) == 0){};
         	resampler(_code, _resampled_signal, _codeFreqBasis, _fs, _codeLength, _samplesPerCode); //resamples code to fs
-        	//delete[] _code;
-        	memcpy (_code, _resampled_signal, _codeLength);
+        	delete[] _code;
+        	_code = _resampled_signal;
         }
 
     for (unsigned int i = 0; i < _samplesPerCode; i++)
diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c
index ef75e17..02bce75 100644
--- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c
+++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/volk_gnsssdr_prefs.c
@@ -34,7 +34,7 @@ void volk_gnsssdr_get_config_path(char *path)
             path[0] = 0;
             return;
         }
-    strcpy(path, home);
+    strncpy(path, home, 512);
     strcat(path, suffix);
 }
 
diff --git a/src/algorithms/observables/gnuradio_blocks/galileo_e1_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/galileo_e1_observables_cc.cc
index 9db61af..7ad6561 100644
--- a/src/algorithms/observables/gnuradio_blocks/galileo_e1_observables_cc.cc
+++ b/src/algorithms/observables/gnuradio_blocks/galileo_e1_observables_cc.cc
@@ -93,14 +93,14 @@ galileo_e1_observables_cc::~galileo_e1_observables_cc()
 
 
 
-bool Galileo_pairCompare_gnss_synchro_Prn_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool Galileo_pairCompare_gnss_synchro_Prn_delay_ms(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Prn_timestamp_ms) < (b.second.Prn_timestamp_ms);
 }
 
 
 
-bool Galileo_pairCompare_gnss_synchro_d_TOW_at_current_symbol( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool Galileo_pairCompare_gnss_synchro_d_TOW_at_current_symbol(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.d_TOW_at_current_symbol) < (b.second.d_TOW_at_current_symbol);
 }
diff --git a/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc
index eb30a7a..0e707c5 100644
--- a/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc
+++ b/src/algorithms/observables/gnuradio_blocks/gps_l1_ca_observables_cc.cc
@@ -90,13 +90,13 @@ gps_l1_ca_observables_cc::~gps_l1_ca_observables_cc()
 }
 
 
-bool pairCompare_gnss_synchro_Prn_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool pairCompare_gnss_synchro_Prn_delay_ms(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Prn_timestamp_ms) < (b.second.Prn_timestamp_ms);
 }
 
 
-bool pairCompare_gnss_synchro_d_TOW_at_current_symbol( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool pairCompare_gnss_synchro_d_TOW_at_current_symbol(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.d_TOW_at_current_symbol) < (b.second.d_TOW_at_current_symbol);
 }
diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc
index 0832aeb..c06af36 100644
--- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc
+++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc
@@ -93,18 +93,18 @@ hybrid_observables_cc::~hybrid_observables_cc()
 
 
 
-bool Hybrid_pairCompare_gnss_synchro_Prn_delay_ms( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool Hybrid_pairCompare_gnss_synchro_Prn_delay_ms(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Prn_timestamp_ms) < (b.second.Prn_timestamp_ms);
 }
 
 
-bool Hybrid_pairCompare_gnss_synchro_d_TOW_hybrid_at_current_symbol( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool Hybrid_pairCompare_gnss_synchro_d_TOW_hybrid_at_current_symbol(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.d_TOW_hybrid_at_current_symbol) < (b.second.d_TOW_hybrid_at_current_symbol);
 }
 
-bool Hybrid_pairCompare_gnss_synchro_d_TOW_at_current_symbol( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool Hybrid_pairCompare_gnss_synchro_d_TOW_at_current_symbol(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.d_TOW_at_current_symbol) < (b.second.d_TOW_at_current_symbol);
 }
diff --git a/src/core/system_parameters/sbas_time.h b/src/core/system_parameters/sbas_time.h
index 2dea4a3..22a158f 100644
--- a/src/core/system_parameters/sbas_time.h
+++ b/src/core/system_parameters/sbas_time.h
@@ -100,6 +100,9 @@ public:
     Sbas_Time()
     {
         e_state = UNDEFINED;
+        i_gps_week = 0;
+        d_gps_sec = 0;
+        d_time_stamp_sec = 0;
     }
 
     Sbas_Time(double time_stamp_sec)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list