Change in osmo-trx[master]: SigProcLib: Use available copyTo Vector API instead of memcopy

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Sep 10 15:30:59 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/10718 )

Change subject: SigProcLib: Use available copyTo Vector API instead of memcopy
......................................................................

SigProcLib: Use available copyTo Vector API instead of memcopy

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<float>’; use copy-assignment or copy-initialization instead [-Werror=class-memaccess]
   midMidamble->size() * sizeof(complex));

Change-Id: Id446711349bec70fa4e7c8efe0f7f9faf7e4f277
---
M CommonLibs/Vector.h
M Transceiver52M/sigProcLib.cpp
2 files changed, 5 insertions(+), 7 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h
index 15d6710..0ba1b9e 100644
--- a/CommonLibs/Vector.h
+++ b/CommonLibs/Vector.h
@@ -107,7 +107,7 @@
 	void clone(const Vector<T>& other)
 	{
 		resize(other.size());
-		memcpy(mData,other.mStart,other.bytes());
+		other.copyTo(*this);
 	}
 
 
diff --git a/Transceiver52M/sigProcLib.cpp b/Transceiver52M/sigProcLib.cpp
index e94170b..2040b36 100644
--- a/Transceiver52M/sigProcLib.cpp
+++ b/Transceiver52M/sigProcLib.cpp
@@ -1262,8 +1262,7 @@
   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 @@
   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 @@
   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 @@
 {
   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) {

-- 
To view, visit https://gerrit.osmocom.org/10718
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id446711349bec70fa4e7c8efe0f7f9faf7e4f277
Gerrit-Change-Number: 10718
Gerrit-PatchSet: 3
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180910/f5b12e3e/attachment.htm>


More information about the gerrit-log mailing list