From 3f2f1fcd7f8c52345e8debba803c722e59c66497 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 15 Nov 2020 00:03:34 +0100 Subject: [PATCH] Fixed -Wclass-memaccess warnings --- plugins/channelrx/demoddatv/leansdr/dvbs2.h | 15 +++++++++-- plugins/channelrx/demoddatv/leansdr/sdr.h | 7 ++++- plugins/channeltx/modatv/atvmodsource.cpp | 4 +-- .../udpsource/udpsourceudphandler.cpp | 3 ++- sdrbase/dsp/fftfilt.cpp | 26 +++++++++---------- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/plugins/channelrx/demoddatv/leansdr/dvbs2.h b/plugins/channelrx/demoddatv/leansdr/dvbs2.h index 08498304d..26455ae2a 100644 --- a/plugins/channelrx/demoddatv/leansdr/dvbs2.h +++ b/plugins/channelrx/demoddatv/leansdr/dvbs2.h @@ -548,7 +548,13 @@ struct s2_frame_receiver : runnable { diffcorr = 0; coarse_count = 0; - memset(hist, 0, sizeof(hist)); + + for (int i = 0; i < 3; i++) + { + hist[i].p = 0; + hist[i].c = 0; + } + state = COARSE_FREQ; } @@ -907,7 +913,12 @@ struct s2_frame_receiver : runnable // Read SOF - memset(hist, 0, sizeof(hist)); + for (int i = 0; i < 3; i++) + { + hist[i].p = 0; + hist[i].c = 0; + } + complex sof_corr = 0; uint32_t sofbits = 0; for (int s = 0; s < sof.LENGTH; ++s) diff --git a/plugins/channelrx/demoddatv/leansdr/sdr.h b/plugins/channelrx/demoddatv/leansdr/sdr.h index 17c6c1f6c..69b48a858 100644 --- a/plugins/channelrx/demoddatv/leansdr/sdr.h +++ b/plugins/channelrx/demoddatv/leansdr/sdr.h @@ -1080,7 +1080,12 @@ struct cstln_receiver : runnable ss_out = _ss_out ? new pipewriter(*_ss_out) : NULL; mer_out = _mer_out ? new pipewriter(*_mer_out) : NULL; cstln_out = _cstln_out ? new pipewriter(*_cstln_out) : NULL; - memset(hist, 0, sizeof(hist)); + + for (int i = 0; i < 3; i++) + { + hist[i].p = 0; + hist[i].c = 0; + } } void set_omega(float _omega, float tol = 10e-6) diff --git a/plugins/channeltx/modatv/atvmodsource.cpp b/plugins/channeltx/modatv/atvmodsource.cpp index 924029ec9..fdd6ac711 100644 --- a/plugins/channeltx/modatv/atvmodsource.cpp +++ b/plugins/channeltx/modatv/atvmodsource.cpp @@ -136,11 +136,11 @@ ATVModSource::ATVModSource() : m_SSBFilter = new fftfilt(0, m_settings.m_rfBandwidth / (float) m_channelSampleRate, m_ssbFftLen); // arbitrary cutoff m_SSBFilterBuffer = new Complex[m_ssbFftLen/2]; // filter returns data exactly half of its size - memset(m_SSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen>>1)); + std::fill(m_SSBFilterBuffer, m_SSBFilterBuffer + (m_ssbFftLen>>1), Complex{0, 0}); m_DSBFilter = new fftfilt((2.0f * m_settings.m_rfBandwidth) / (float) m_channelSampleRate, 2*m_ssbFftLen); // arbitrary cutoff m_DSBFilterBuffer = new Complex[m_ssbFftLen]; - memset(m_DSBFilterBuffer, 0, sizeof(Complex)*(m_ssbFftLen)); + std::fill(m_DSBFilterBuffer, m_DSBFilterBuffer + m_ssbFftLen, Complex{0, 0}); m_interpolatorDistanceRemain = 0.0f; m_interpolatorDistance = 1.0f; diff --git a/plugins/channeltx/udpsource/udpsourceudphandler.cpp b/plugins/channeltx/udpsource/udpsourceudphandler.cpp index 6dedb9706..67c942aeb 100644 --- a/plugins/channeltx/udpsource/udpsourceudphandler.cpp +++ b/plugins/channeltx/udpsource/udpsourceudphandler.cpp @@ -187,7 +187,8 @@ void UDPSourceUDPHandler::readSample(Sample &s) } else { - memcpy(&s, &m_udpBuf[m_readFrameIndex][m_readIndex], sizeof(Sample)); + Sample *u = (Sample *) &m_udpBuf[m_readFrameIndex][m_readIndex]; + s = *u; advanceReadPointer((int) sizeof(Sample)); } } diff --git a/sdrbase/dsp/fftfilt.cpp b/sdrbase/dsp/fftfilt.cpp index 5953ecaf0..b350c8177 100644 --- a/sdrbase/dsp/fftfilt.cpp +++ b/sdrbase/dsp/fftfilt.cpp @@ -59,11 +59,11 @@ void fftfilt::init_filter() output = new cmplx[flen2]; ovlbuf = new cmplx[flen2]; - memset(filter, 0, flen * sizeof(cmplx)); - memset(filterOpp, 0, flen * sizeof(cmplx)); - memset(data, 0, flen * sizeof(cmplx)); - memset(output, 0, flen2 * sizeof(cmplx)); - memset(ovlbuf, 0, flen2 * sizeof(cmplx)); + std::fill(filter, filter + flen, cmplx{0, 0}); + std::fill(filterOpp, filterOpp + flen, cmplx{0, 0}); + std::fill(data, data + flen , cmplx{0, 0}); + std::fill(output, output + flen2, cmplx{0, 0}); + std::fill(ovlbuf, ovlbuf + flen2, cmplx{0, 0}); inptr = 0; } @@ -115,7 +115,7 @@ fftfilt::~fftfilt() void fftfilt::create_filter(float f1, float f2) { // initialize the filter to zero - memset(filter, 0, flen * sizeof(cmplx)); + std::fill(filter, filter + flen, cmplx{0, 0}); // create the filter shape coefficients by fft bool b_lowpass, b_highpass; @@ -156,7 +156,7 @@ void fftfilt::create_filter(float f1, float f2) void fftfilt::create_dsb_filter(float f2) { // initialize the filter to zero - memset(filter, 0, flen * sizeof(cmplx)); + std::fill(filter, filter + flen, cmplx{0, 0}); for (int i = 0; i < flen2; i++) { filter[i] = fsinc(f2, i, flen2); @@ -183,7 +183,7 @@ void fftfilt::create_asym_filter(float fopp, float fin) { // in band // initialize the filter to zero - memset(filter, 0, flen * sizeof(cmplx)); + std::fill(filter, filter + flen, cmplx{0, 0}); for (int i = 0; i < flen2; i++) { filter[i] = fsinc(fin, i, flen2); @@ -205,7 +205,7 @@ void fftfilt::create_asym_filter(float fopp, float fin) // opposite band // initialize the filter to zero - memset(filterOpp, 0, flen * sizeof(cmplx)); + std::fill(filterOpp, filterOpp + flen, cmplx{0, 0}); for (int i = 0; i < flen2; i++) { filterOpp[i] = fsinc(fopp, i, flen2); @@ -282,7 +282,7 @@ int fftfilt::runFilt(const cmplx & in, cmplx **out) output[i] = ovlbuf[i] + data[i]; ovlbuf[i] = data[flen2 + i]; } - memset (data, 0, flen * sizeof(cmplx)); + std::fill(data, data + flen , cmplx{0, 0}); *out = output; return flen2; @@ -325,7 +325,7 @@ int fftfilt::runSSB(const cmplx & in, cmplx **out, bool usb, bool getDC) output[i] = ovlbuf[i] + data[i]; ovlbuf[i] = data[i+flen2]; } - memset (data, 0, flen * sizeof(cmplx)); + std::fill(data, data + flen , cmplx{0, 0}); *out = output; return flen2; @@ -358,7 +358,7 @@ int fftfilt::runDSB(const cmplx & in, cmplx **out, bool getDC) ovlbuf[i] = data[i+flen2]; } - memset (data, 0, flen * sizeof(cmplx)); + std::fill(data, data + flen , cmplx{0, 0}); *out = output; return flen2; @@ -402,7 +402,7 @@ int fftfilt::runAsym(const cmplx & in, cmplx **out, bool usb) ovlbuf[i] = data[i+flen2]; } - memset (data, 0, flen * sizeof(cmplx)); + std::fill(data, data + flen , cmplx{0, 0}); *out = output; return flen2;