[PATCH 1/7] msgb: Add may_alias attribute to struct libgb_msgb_cb

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Tue Oct 8 10:04:41 UTC 2013


This explicitely allows aliasing of this struct to avoid the warning
shown below. Note, that this warning isn't show when
'-fno-strict-aliasing' is used.

Addresses:
gb/gprs_ns_test.c:85:54: warning: dereferencing type-punned pointer will
break strict-aliasing rules [-Wstrict-aliasing]
---
 include/osmocom/gprs/gprs_msgb.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/osmocom/gprs/gprs_msgb.h b/include/osmocom/gprs/gprs_msgb.h
index f4c8554..e277696 100644
--- a/include/osmocom/gprs/gprs_msgb.h
+++ b/include/osmocom/gprs/gprs_msgb.h
@@ -16,7 +16,7 @@ struct libgb_msgb_cb {
 
 	/* Identifier of a MS (inside BTS), equal to 'struct sgsn_mm_ctx' */
 	uint32_t tlli;
-} __attribute__((packed));
+} __attribute__((packed, may_alias));
 #define LIBGB_MSGB_CB(__msgb)	((struct libgb_msgb_cb *)&((__msgb)->cb[0]))
 #define msgb_tlli(__x)		LIBGB_MSGB_CB(__x)->tlli
 #define msgb_nsei(__x)		LIBGB_MSGB_CB(__x)->nsei
-- 
1.7.9.5





More information about the OpenBSC mailing list