From 946d3dae9f834a075059d696732de85019841dce Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 25 Feb 2018 13:27:27 +0100 Subject: [PATCH 1/3] Replace memset by std::fill_n. This fix warnings in GCC 8.0.1 (Fedora Rawhide). The warnings were: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct std::complex'; use assignment or value-initialization instead [-Wclass-memaccess] --- .../gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc | 4 ++-- src/tests/unit-tests/arithmetic/conjugate_test.cc | 6 +++--- src/tests/unit-tests/arithmetic/magnitude_squared_test.cc | 4 ++-- src/tests/unit-tests/arithmetic/multiply_test.cc | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 0aa8f1410..fc36cfa85 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -31,7 +31,7 @@ */ #include "pcps_acquisition_fine_doppler_cc.h" -#include // std::rotate +#include // std::rotate, std::fill_n #include #include #include @@ -331,7 +331,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star gr::fft::fft_complex *fft_operator = new gr::fft::fft_complex(fft_size_extended, true); //zero padding the entire vector - memset(fft_operator->get_inbuf(), 0, fft_size_extended * sizeof(gr_complex)); + std::fill_n(fft_operator->get_inbuf(), fft_size_extended, gr_complex(0.0, 0.0)); //1. generate local code aligned with the acquisition code phase estimation gr_complex *code_replica = static_cast(volk_gnsssdr_malloc(d_fft_size * sizeof(gr_complex), volk_gnsssdr_get_alignment())); diff --git a/src/tests/unit-tests/arithmetic/conjugate_test.cc b/src/tests/unit-tests/arithmetic/conjugate_test.cc index 1b0aaa8cb..9867b5584 100644 --- a/src/tests/unit-tests/arithmetic/conjugate_test.cc +++ b/src/tests/unit-tests/arithmetic/conjugate_test.cc @@ -29,7 +29,7 @@ * ------------------------------------------------------------------------- */ - +#include #include #include #include @@ -44,7 +44,7 @@ TEST(ConjugateTest, StandardCComplexImplementation) { std::complex* input = new std::complex[FLAGS_size_conjugate_test]; std::complex* output = new std::complex[FLAGS_size_conjugate_test]; - memset(input, 0, sizeof(std::complex) * FLAGS_size_conjugate_test); + std::fill_n(input, FLAGS_size_conjugate_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -118,7 +118,7 @@ TEST(ConjugateTest, VolkComplexImplementation) { std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); std::complex* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_conjugate_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); - memset(input, 0, sizeof(std::complex) * FLAGS_size_conjugate_test); + std::fill_n(input, FLAGS_size_conjugate_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); diff --git a/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc b/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc index 6238b5c75..cefa52e21 100644 --- a/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc +++ b/src/tests/unit-tests/arithmetic/magnitude_squared_test.cc @@ -30,7 +30,7 @@ * ------------------------------------------------------------------------- */ - +#include #include #include #include @@ -115,7 +115,7 @@ TEST(MagnitudeSquaredTest, ArmadilloComplexImplementation) TEST(MagnitudeSquaredTest, VolkComplexImplementation) { std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); - memset(input, 0, sizeof(std::complex) * FLAGS_size_magnitude_test); + std::fill_n(input, FLAGS_size_magnitude_test, std::complex(0.0, 0.0)); float* output = static_cast(volk_gnsssdr_malloc(FLAGS_size_magnitude_test * sizeof(float), volk_gnsssdr_get_alignment())); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); diff --git a/src/tests/unit-tests/arithmetic/multiply_test.cc b/src/tests/unit-tests/arithmetic/multiply_test.cc index 093bca5f9..809ff8d11 100644 --- a/src/tests/unit-tests/arithmetic/multiply_test.cc +++ b/src/tests/unit-tests/arithmetic/multiply_test.cc @@ -30,7 +30,7 @@ * ------------------------------------------------------------------------- */ - +#include #include #include #include @@ -45,7 +45,7 @@ TEST(MultiplyTest, StandardCDoubleImplementation) { double* input = new double[FLAGS_size_multiply_test]; double* output = new double[FLAGS_size_multiply_test]; - memset(input, 0, sizeof(double) * FLAGS_size_multiply_test); + std::fill_n(input, FLAGS_size_multiply_test, 0.0); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -98,7 +98,7 @@ TEST(MultiplyTest, StandardCComplexImplementation) { std::complex* input = new std::complex[FLAGS_size_multiply_test]; std::complex* output = new std::complex[FLAGS_size_multiply_test]; - memset(input, 0, sizeof(std::complex) * FLAGS_size_multiply_test); + std::fill_n(input, FLAGS_size_multiply_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); @@ -180,7 +180,7 @@ TEST(MultiplyTest, VolkComplexImplementation) { std::complex* input = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); std::complex* output = static_cast*>(volk_gnsssdr_malloc(FLAGS_size_multiply_test * sizeof(std::complex), volk_gnsssdr_get_alignment())); - memset(input, 0, sizeof(std::complex) * FLAGS_size_multiply_test); + std::fill_n(input, FLAGS_size_multiply_test, std::complex(0.0, 0.0)); std::chrono::time_point start, end; start = std::chrono::system_clock::now(); From e17f9268a8af0346c47378f1a9a43ccd6a465f42 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 25 Feb 2018 13:29:01 +0100 Subject: [PATCH 2/3] Fix warning in GCC 8.0.1 (Fedora Rawhide) The warning was: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] --- src/core/libs/supl/supl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/libs/supl/supl.c b/src/core/libs/supl/supl.c index 6a06bb252..021b65327 100644 --- a/src/core/libs/supl/supl.c +++ b/src/core/libs/supl/supl.c @@ -221,7 +221,7 @@ int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { SSLeay_add_ssl_algorithms(); // meth = TLSv1_client_method(); - meth = SSLv23_client_method(); + meth = (SSL_METHOD*)SSLv23_client_method(); SSL_load_error_strings(); ctx->ssl_ctx = SSL_CTX_new(meth); if (!ctx->ssl_ctx) return E_SUPL_CONNECT; From 5c77a394d7850fb68d3873c0af0eab682b298438 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 25 Feb 2018 13:34:13 +0100 Subject: [PATCH 3/3] Replace memset by std::fill_n --- .../gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index fc36cfa85..0f80cf3bd 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -366,7 +366,7 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler(gr_vector_const_void_star int counter = 0; float fftFreqBins[fft_size_extended]; - memset(fftFreqBins, 0, fft_size_extended * sizeof(float)); + std::fill_n(fftFreqBins, fft_size_extended, 0.0); for (int k = 0; k < (fft_size_extended / 2); k++) {