summaryrefslogtreecommitdiff
path: root/gr-qtgui
diff options
context:
space:
mode:
authorAnders Kalør <anders@kaloer.com>2019-08-17 14:33:21 +0200
committerMartin Braun <martin.braun@ettus.com>2019-08-22 15:59:00 -0700
commit943f3c1942f4ca080c964480e4fd75c4d2a930d6 (patch)
treef8a8707f838f4e89cb2db51ce89d135a994b5faa /gr-qtgui
parentd301bc9f4155b6570e5ae365fde8b58ca6f72df3 (diff)
Fix memset clearing non-trivial type gr_complex warnings in gcc-8
Using memset with gr_complex is not a problem since the underlying representation of gr_complex is guaranteed to be two floats in adjacent memory locations without padding or additional memory. Fixes #2743
Diffstat (limited to 'gr-qtgui')
-rw-r--r--gr-qtgui/lib/freq_sink_c_impl.cc11
-rw-r--r--gr-qtgui/lib/time_sink_c_impl.cc7
-rw-r--r--gr-qtgui/lib/waterfall_sink_c_impl.cc13
3 files changed, 17 insertions, 14 deletions
diff --git a/gr-qtgui/lib/freq_sink_c_impl.cc b/gr-qtgui/lib/freq_sink_c_impl.cc
index b692f458ac..3a34df6ec6 100644
--- a/gr-qtgui/lib/freq_sink_c_impl.cc
+++ b/gr-qtgui/lib/freq_sink_c_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012,2014-2015 Free Software Foundation, Inc.
+ * Copyright 2012,2014-2015,2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -33,6 +33,7 @@
#include <volk/volk.h>
#include <string.h>
+#include <algorithm>
namespace gr {
namespace qtgui {
@@ -111,7 +112,7 @@ freq_sink_c_impl::freq_sink_c_impl(int fftsize,
d_magbufs.push_back(
(double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[i], d_fftsize, 0);
memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
}
@@ -119,7 +120,7 @@ freq_sink_c_impl::freq_sink_c_impl(int fftsize,
(gr_complex*)volk_malloc(d_fftsize * sizeof(gr_complex), volk_get_alignment()));
d_pdu_magbuf = (double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment());
d_magbufs.push_back(d_pdu_magbuf);
- memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[d_nconnections], d_fftsize, 0);
memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double));
buildwindow();
@@ -442,7 +443,7 @@ bool freq_sink_c_impl::fftresize()
d_magbufs[i] =
(double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[i], newfftsize, 0);
memset(d_magbufs[i], 0, newfftsize * sizeof(double));
}
@@ -672,7 +673,7 @@ void freq_sink_c_impl::handle_pdus(pmt::pmt_t msg)
size_t max = std::min(d_fftsize, static_cast<int>(len));
for (int n = 0; n < nffts; n++) {
// Clear in case (max-min) < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex) * d_fftsize);
+ std::fill_n(d_residbufs[d_nconnections], d_fftsize, 0x00);
// Copy in as much of the input samples as we can
memcpy(
diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc
index a05672f831..b73a1c1ad3 100644
--- a/gr-qtgui/lib/time_sink_c_impl.cc
+++ b/gr-qtgui/lib/time_sink_c_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2011-2013,2015 Free Software Foundation, Inc.
+ * Copyright 2011-2013,2015,2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -34,6 +34,7 @@
#include <volk/volk.h>
#include <string.h>
+#include <algorithm>
namespace gr {
namespace qtgui {
@@ -92,7 +93,7 @@ time_sink_c_impl::time_sink_c_impl(int size,
for (unsigned int n = 0; n < d_nconnections / 2; n++) {
d_cbuffers.push_back((gr_complex*)volk_malloc(d_buffer_size * sizeof(gr_complex),
volk_get_alignment()));
- memset(d_cbuffers[n], 0, d_buffer_size * sizeof(gr_complex));
+ std::fill_n(d_cbuffers[n], d_buffer_size, 0);
}
// Set alignment properties for VOLK
@@ -323,7 +324,7 @@ void time_sink_c_impl::set_nsamps(const int newsize)
volk_free(d_cbuffers[n]);
d_cbuffers[n] = (gr_complex*)volk_malloc(d_buffer_size * sizeof(gr_complex),
volk_get_alignment());
- memset(d_cbuffers[n], 0, d_buffer_size * sizeof(gr_complex));
+ std::fill_n(d_cbuffers[n], d_buffer_size, 0);
}
// If delay was set beyond the new boundary, pull it back.
diff --git a/gr-qtgui/lib/waterfall_sink_c_impl.cc b/gr-qtgui/lib/waterfall_sink_c_impl.cc
index 121023d528..b94e6a8836 100644
--- a/gr-qtgui/lib/waterfall_sink_c_impl.cc
+++ b/gr-qtgui/lib/waterfall_sink_c_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2012,2014-2015 Free Software Foundation, Inc.
+ * Copyright 2012,2014-2015,2019 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -34,6 +34,7 @@
#include <string.h>
#include <iostream>
+#include <algorithm>
namespace gr {
namespace qtgui {
@@ -98,7 +99,7 @@ waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize,
volk_get_alignment()));
d_magbufs.push_back(
(double*)volk_malloc(d_fftsize * sizeof(double), volk_get_alignment()));
- memset(d_residbufs[i], 0, d_fftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[i], d_fftsize, 0);
memset(d_magbufs[i], 0, d_fftsize * sizeof(double));
}
@@ -108,7 +109,7 @@ waterfall_sink_c_impl::waterfall_sink_c_impl(int fftsize,
(double*)volk_malloc(d_fftsize * sizeof(double) * d_nrows, volk_get_alignment());
d_magbufs.push_back(d_pdu_magbuf);
memset(d_pdu_magbuf, 0, d_fftsize * sizeof(double) * d_nrows);
- memset(d_residbufs[d_nconnections], 0, d_fftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[d_nconnections], d_fftsize, 0);
buildwindow();
@@ -371,7 +372,7 @@ void waterfall_sink_c_impl::fftresize()
d_magbufs[i] =
(double*)volk_malloc(newfftsize * sizeof(double), volk_get_alignment());
- memset(d_residbufs[i], 0, newfftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[i], newfftsize, 0);
memset(d_magbufs[i], 0, newfftsize * sizeof(double));
}
@@ -385,7 +386,7 @@ void waterfall_sink_c_impl::fftresize()
d_pdu_magbuf = (double*)volk_malloc(newfftsize * sizeof(double) * d_nrows,
volk_get_alignment());
d_magbufs[d_nconnections] = d_pdu_magbuf;
- memset(d_residbufs[d_nconnections], 0, newfftsize * sizeof(gr_complex));
+ std::fill_n(d_residbufs[d_nconnections], newfftsize, 0);
memset(d_pdu_magbuf, 0, newfftsize * sizeof(double) * d_nrows);
// Set new fft size and reset buffer index
@@ -558,7 +559,7 @@ void waterfall_sink_c_impl::handle_pdus(pmt::pmt_t msg)
size_t max = std::min(d_fftsize, static_cast<int>(len));
for (size_t i = 0; j < d_nrows; i += stride) {
// Clear residbufs if len < d_fftsize
- memset(d_residbufs[d_nconnections], 0x00, sizeof(gr_complex) * d_fftsize);
+ std::fill_n(d_residbufs[d_nconnections], d_fftsize, 0x00);
// Copy in as much of the input samples as we can
memcpy(