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

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Wed Sep 2 00:22:38 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 4850944e0036d6c1481e461d605190d76e97b3c9
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Fri May 15 03:02:45 2015 +0200

    fixing coverity issues
---
 src/algorithms/PVT/adapters/galileo_e1_pvt.h            |  2 +-
 src/algorithms/PVT/adapters/gps_l1_ca_pvt.h             |  1 -
 src/algorithms/PVT/adapters/hybrid_pvt.h                |  1 -
 src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc |  2 +-
 src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h  |  2 +-
 src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc  |  2 +-
 src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc     |  3 +--
 src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h      |  4 +---
 src/algorithms/PVT/libs/rinex_printer.cc                | 14 ++++++++------
 .../acquisition/adapters/gps_l1_ca_pcps_acquisition.cc  |  4 ++++
 .../acquisition/gnuradio_blocks/pcps_acquisition_cc.cc  | 16 +++++++---------
 .../acquisition/gnuradio_blocks/pcps_acquisition_cc.h   |  2 +-
 src/tests/test_main.cc                                  | 17 +++++++++++++----
 13 files changed, 39 insertions(+), 31 deletions(-)

diff --git a/src/algorithms/PVT/adapters/galileo_e1_pvt.h b/src/algorithms/PVT/adapters/galileo_e1_pvt.h
index a399356..e8f6222 100644
--- a/src/algorithms/PVT/adapters/galileo_e1_pvt.h
+++ b/src/algorithms/PVT/adapters/galileo_e1_pvt.h
@@ -86,7 +86,7 @@ public:
 private:
     galileo_e1_pvt_cc_sptr pvt_;
     bool dump_;
-    unsigned int fs_in_;
+    //unsigned int fs_in_;
     std::string dump_filename_;
     std::string role_;
     unsigned int in_streams_;
diff --git a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h
index 63d0404..1497247 100644
--- a/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h
+++ b/src/algorithms/PVT/adapters/gps_l1_ca_pvt.h
@@ -88,7 +88,6 @@ public:
 private:
     gps_l1_ca_pvt_cc_sptr pvt_;
     bool dump_;
-    unsigned int fs_in_;
     std::string dump_filename_;
     std::string role_;
     unsigned int in_streams_;
diff --git a/src/algorithms/PVT/adapters/hybrid_pvt.h b/src/algorithms/PVT/adapters/hybrid_pvt.h
index 4bcf7fc..ae2b6ad 100644
--- a/src/algorithms/PVT/adapters/hybrid_pvt.h
+++ b/src/algorithms/PVT/adapters/hybrid_pvt.h
@@ -86,7 +86,6 @@ public:
 private:
     hybrid_pvt_cc_sptr pvt_;
     bool dump_;
-    unsigned int fs_in_;
     std::string dump_filename_;
     std::string role_;
     unsigned int in_streams_;
diff --git a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc
index 76b1eb4..e991f5d 100644
--- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc
+++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.cc
@@ -121,7 +121,7 @@ galileo_e1_pvt_cc::~galileo_e1_pvt_cc()
 
 
 
-bool galileo_e1_pvt_cc::pseudoranges_pairCompare_min( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool galileo_e1_pvt_cc::pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Pseudorange_m) < (b.second.Pseudorange_m);
 }
diff --git a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h
index 49952af..2dfd1d9 100644
--- a/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h
+++ b/src/algorithms/PVT/gnuradio_blocks/galileo_e1_pvt_cc.h
@@ -111,7 +111,7 @@ private:
     std::shared_ptr<Nmea_Printer> d_nmea_printer;
     double d_rx_time;
     std::shared_ptr<galileo_e1_ls_pvt> d_ls_pvt;
-    bool pseudoranges_pairCompare_min(std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b);
+    bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b);
 
 public:
     ~galileo_e1_pvt_cc (); //!< Default destructor
diff --git a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc
index cae5e0b..7ad3e2d 100644
--- a/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc
+++ b/src/algorithms/PVT/gnuradio_blocks/gps_l1_ca_pvt_cc.cc
@@ -136,7 +136,7 @@ gps_l1_ca_pvt_cc::~gps_l1_ca_pvt_cc()
 
 
 
-bool pseudoranges_pairCompare_min( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Pseudorange_m) < (b.second.Pseudorange_m);
 }
diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc
index d9d31b5..3502429 100644
--- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc
+++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.cc
@@ -93,7 +93,6 @@ hybrid_pvt_cc::hybrid_pvt_cc(unsigned int nchannels, boost::shared_ptr<gr::msg_q
     d_ls_pvt->set_averaging_depth(d_averaging_depth);
 
     d_sample_counter = 0;
-    valid_solution_counter = 0;
     d_last_sample_nav_output = 0;
     d_rx_time = 0.0;
     d_TOW_at_curr_symbol_constellation = 0.0;
@@ -127,7 +126,7 @@ hybrid_pvt_cc::~hybrid_pvt_cc()
 
 
 
-bool hybrid_pvt_cc::pseudoranges_pairCompare_min( std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b)
+bool hybrid_pvt_cc::pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b)
 {
     return (a.second.Pseudorange_m) < (b.second.Pseudorange_m);
 }
diff --git a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h
index dad4a22..2ac6b1e 100644
--- a/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h
+++ b/src/algorithms/PVT/gnuradio_blocks/hybrid_pvt_cc.h
@@ -110,15 +110,13 @@ private:
     int d_output_rate_ms;
     int d_display_rate_ms;
     long unsigned int d_sample_counter;
-    long unsigned int valid_solution_counter;
-    long unsigned int valid_solution_16_sat_counter;
     long unsigned int d_last_sample_nav_output;
     std::shared_ptr<Kml_Printer> d_kml_dump;
     std::shared_ptr<Nmea_Printer> d_nmea_printer;
     double d_rx_time;
     double d_TOW_at_curr_symbol_constellation;
     std::shared_ptr<hybrid_ls_pvt> d_ls_pvt;
-    bool pseudoranges_pairCompare_min(std::pair<int,Gnss_Synchro> a, std::pair<int,Gnss_Synchro> b);
+    bool pseudoranges_pairCompare_min(const std::pair<int,Gnss_Synchro>& a, const std::pair<int,Gnss_Synchro>& b);
 
 public:
     ~hybrid_pvt_cc (); //!< Default destructor
diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc
index 75020c3..a65142a 100644
--- a/src/algorithms/PVT/libs/rinex_printer.cc
+++ b/src/algorithms/PVT/libs/rinex_printer.cc
@@ -173,7 +173,9 @@ Rinex_Printer::Rinex_Printer()
         }
     else
         {
-            LOG(ERROR) << "Unknown RINEX version " << FLAGS_RINEX_version << " (must be 2.11 or 3.02)" << std::endl;
+            LOG(WARNING) << "Unknown RINEX version " << FLAGS_RINEX_version << " (must be 2.11 or 3.02). Using 3.02";
+            version = 3;
+            stringVersion = "3.02";
         }
 
     numberTypesObservations = 4; // Number of available types of observable in the system
@@ -197,23 +199,23 @@ Rinex_Printer::~Rinex_Printer()
     // If nothing written, erase the files.
     if (posn == 0)
         {
-            remove(navfilename.c_str());
+            if(remove(navfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
         }
     if (poso == 0)
         {
-            remove(obsfilename.c_str());
+            if(remove(obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
         }
     if (poss == 0)
         {
-            remove(sbsfilename.c_str());
+            if(remove(sbsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
         }
     if (posng == 0)
         {
-            remove(navGalfilename.c_str());
+            if(remove(navGalfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
         }
     if (posmn == 0)
         {
-            remove(navMixfilename.c_str());
+            if(remove(navMixfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file";
         }
 }
 
diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc
index 234859b..22f1699 100644
--- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc
+++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc
@@ -117,6 +117,10 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition(
     //     LOG(WARNING) << item_type_
     //             << " unknown acquisition item type";
     // }
+    channel_ = 0;
+    threshold_ = 0.0;
+    doppler_max_ = 0;
+    doppler_step_ = 0;
 }
 
 
diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
index ef3e6ce..bc6d5c0 100644
--- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
+++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc
@@ -85,6 +85,12 @@ pcps_acquisition_cc::pcps_acquisition_cc(
     d_input_power = 0.0;
     d_num_doppler_bins = 0;
     d_bit_transition_flag = bit_transition_flag;
+    d_threshold = 0.0;
+    d_doppler_step = 250;
+    d_code_phase = 0;
+    d_test_statistics = 0.0;
+    d_channel = 0;
+    d_doppler_freq = 0.0;
 
     d_fft_codes = static_cast<gr_complex*>(volk_malloc(d_fft_size * sizeof(gr_complex), volk_get_alignment()));
     d_magnitude = static_cast<float*>(volk_malloc(d_fft_size * sizeof(float), volk_get_alignment()));
@@ -138,15 +144,7 @@ void pcps_acquisition_cc::init()
     d_mag = 0.0;
     d_input_power = 0.0;
 
-    d_num_doppler_bins=ceil((static_cast<int>(d_doppler_max)-static_cast<int>(-d_doppler_max))/d_doppler_step);
-    // Count the number of bins
-//    d_num_doppler_bins = 0;
-//    for (int doppler = static_cast<int>(-d_doppler_max);
-//         doppler <= static_cast<int>(d_doppler_max);
-//         doppler += d_doppler_step)
-//    {
-//        d_num_doppler_bins++;
-//    }
+    d_num_doppler_bins = ceil( static_cast<double>(static_cast<int>(d_doppler_max) - static_cast<int>(-d_doppler_max)) / static_cast<double>(d_doppler_step));
 
     // Create the carrier Doppler wipeoff signals
     d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins];
diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h
index a0f7674..168e62c 100644
--- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h
+++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.h
@@ -105,7 +105,7 @@ private:
     long d_freq;
     int d_samples_per_ms;
     int d_samples_per_code;
-    unsigned int d_doppler_resolution;
+    //unsigned int d_doppler_resolution;
     float d_threshold;
     std::string d_satellite_str;
     unsigned int d_doppler_max;
diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc
index 538e903..f10e939 100644
--- a/src/tests/test_main.cc
+++ b/src/tests/test_main.cc
@@ -153,8 +153,17 @@ concurrent_map<Sbas_Ephemeris> global_sbas_ephemeris_map;
 int main(int argc, char **argv)
 {
     std::cout << "Running GNSS-SDR Tests..." << std::endl;
-    testing::InitGoogleTest(&argc, argv);
-    google::ParseCommandLineFlags(&argc, &argv, true);
-    google::InitGoogleLogging(argv[0]);
-    return RUN_ALL_TESTS();
+    try
+    {
+            testing::InitGoogleTest(&argc, argv);
+            google::ParseCommandLineFlags(&argc, &argv, true);
+            google::InitGoogleLogging(argv[0]);
+            return RUN_ALL_TESTS();
+    }
+    catch(const testing::internal::GoogleTestFailureException& e)
+    {
+            std::cout << e.what() << std::endl;
+    }
+    catch(...)
+    {}
 }

-- 
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