From 5e68cde779dc6ef4f84f32422c25c558dea650d3 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 30 Aug 2018 20:45:14 +0200 Subject: [PATCH] SigProcLib: Use available copyTo Vector API instead of memcopy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change allows to remove some wrong use of code as per compilation warning: osmo-trx/Transceiver52M/sigProcLib.cpp:1266:40: error: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of non-trivially copyable type ‘class Complex’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess] midMidamble->size() * sizeof(complex)); Change-Id: Id446711349bec70fa4e7c8efe0f7f9faf7e4f277 --- CommonLibs/Vector.h | 2 +- Transceiver52M/sigProcLib.cpp | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h index 15d6710b..0ba1b9e4 100644 --- a/CommonLibs/Vector.h +++ b/CommonLibs/Vector.h @@ -107,7 +107,7 @@ template class Vector { void clone(const Vector& other) { resize(other.size()); - memcpy(mData,other.mStart,other.bytes()); + other.copyTo(*this); } diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp index e94170b2..2040b365 100644 --- a/Transceiver52M/sigProcLib.cpp +++ b/Transceiver52M/sigProcLib.cpp @@ -1262,8 +1262,7 @@ static bool generateMidamble(int sps, int tsc) data = (complex *) convolve_h_alloc(midMidamble->size()); _midMidamble = new signalVector(data, 0, midMidamble->size()); _midMidamble->setAligned(true); - memcpy(_midMidamble->begin(), midMidamble->begin(), - midMidamble->size() * sizeof(complex)); + midMidamble->copyTo(*_midMidamble); autocorr = convolve(midamble, _midMidamble, NULL, NO_DELAY); if (!autocorr) { @@ -1319,8 +1318,7 @@ static CorrelationSequence *generateEdgeMidamble(int tsc) data = (complex *) convolve_h_alloc(midamble->size()); _midamble = new signalVector(data, 0, midamble->size()); _midamble->setAligned(true); - memcpy(_midamble->begin(), midamble->begin(), - midamble->size() * sizeof(complex)); + midamble->copyTo(*_midamble); /* Channel gain is an empirically measured value */ seq = new CorrelationSequence; @@ -1360,7 +1358,7 @@ static bool generateRACHSequence(int sps) data = (complex *) convolve_h_alloc(seq1->size()); _seq1 = new signalVector(data, 0, seq1->size()); _seq1->setAligned(true); - memcpy(_seq1->begin(), seq1->begin(), seq1->size() * sizeof(complex)); + seq1->copyTo(*_seq1); autocorr = convolve(seq0, _seq1, autocorr, NO_DELAY); if (!autocorr) { @@ -1457,7 +1455,7 @@ static signalVector *downsampleBurst(const signalVector &burst) { signalVector in(DOWNSAMPLE_IN_LEN, dnsampler->len()); signalVector *out = new signalVector(DOWNSAMPLE_OUT_LEN); - memcpy(in.begin(), burst.begin(), DOWNSAMPLE_IN_LEN * 2 * sizeof(float)); + burst.copyToSegment(in, 0, DOWNSAMPLE_IN_LEN); if (dnsampler->rotate((float *) in.begin(), DOWNSAMPLE_IN_LEN, (float *) out->begin(), DOWNSAMPLE_OUT_LEN) < 0) {