Change in osmo-pcu[master]: tbf: Fix memset(0) on object with no trivial copy-assignment

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
Wed May 16 13:23:20 UTC 2018


Pau Espin Pedrol has uploaded this change for review. ( https://gerrit.osmocom.org/9200


Change subject: tbf: Fix memset(0) on object with no trivial copy-assignment
......................................................................

tbf: Fix memset(0) on object with no trivial copy-assignment

As warned by gcc 8.1.0:
osmo-pcu/src/tbf.cpp: In constructor ‘gprs_rlcmac_tbf::gprs_rlcmac_tbf(BTS*, gprs_rlcmac_tbf_direction)’:
osmo-pcu/src/tbf.cpp:222:33: error: ‘void* memset(void*, int, size_t)’ clearing an object of type ‘struct gprs_rlc’ with no trivial copy-assignment; use assignment or value-initialization instead [-Werror=class-memaccess]
  memset(&m_rlc, 0, sizeof(m_rlc));
                                 ^
In file included from osmo-pcu/src/tbf.h:24,
                 from osmo-pcu/src/bts.h:37,
                 from osmo-pcu/src/tbf.cpp:22:
osmo-pcu/src/rlc.h:234:8: note: ‘struct gprs_rlc’ declared here
 struct gprs_rlc {
        ^~~~~~~~

Change-Id: Ifb0529b9ae6cd4300e5cbbd9151054792edbfe06
---
M src/rlc.h
M src/tbf.cpp
2 files changed, 8 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/00/9200/1

diff --git a/src/rlc.h b/src/rlc.h
index aac6b13..5b6a0dd 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -24,6 +24,7 @@
 #include <osmocom/core/endian.h>
 
 #include <stdint.h>
+#include <string.h>
 
 #define RLC_GPRS_SNS 128 /* GPRS, must be power of 2 */
 #define RLC_GPRS_WS  64 /* max window size */
@@ -232,6 +233,7 @@
  * the routines to manipulate these arrays.
  */
 struct gprs_rlc {
+	void init();
 	gprs_rlc_data *block(int bsn);
 	gprs_rlc_data m_blocks[RLC_MAX_SNS/2];
 };
@@ -647,6 +649,11 @@
 	return m_v_n[bsn & mod_sns_half()];
 }
 
+inline void gprs_rlc::init()
+{
+	memset(m_blocks, 0, sizeof(m_blocks));
+}
+
 inline gprs_rlc_data *gprs_rlc::block(int bsn)
 {
 	return &m_blocks[bsn & mod_sns_half()];
diff --git a/src/tbf.cpp b/src/tbf.cpp
index d5fbb3f..14c1ee2 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -219,9 +219,9 @@
 	memset(&pdch, 0, sizeof(pdch));
 	memset(&T, 0, sizeof(T));
 	memset(&N, 0, sizeof(N));
-	memset(&m_rlc, 0, sizeof(m_rlc));
 	memset(&gsm_timer, 0, sizeof(gsm_timer));
 
+	m_rlc.init();
 	m_llc.init();
 
 	m_name_buf[0] = '\0';

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb0529b9ae6cd4300e5cbbd9151054792edbfe06
Gerrit-Change-Number: 9200
Gerrit-PatchSet: 1
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180516/77d42417/attachment.htm>


More information about the gerrit-log mailing list