Change in libosmo-sccp[master]: xua_test: fix gcc 4 + -std=gnu11 error

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/.

laforge gerrit-no-reply at lists.osmocom.org
Tue Feb 2 17:57:02 UTC 2021


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/22629 )

Change subject: xua_test: fix gcc 4 + -std=gnu11 error
......................................................................

xua_test: fix gcc 4 + -std=gnu11 error

Fix 'error: initializer element is not constant' with debian 8's gcc
4.9.2, triggered by XUA_HDR. Create a new _XUA_HDR without the type cast,
and use it inside of const struct definitions in xua_test.c. The new
macro is needed, because removing the type cast from the original
XUA_HDR would break other uses.

Related: OS#5004
Change-Id: I890432ee976043d012b01023f7dd2cfecf79d115
---
M tests/xua/xua_test.c
1 file changed, 14 insertions(+), 11 deletions(-)

Approvals:
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/tests/xua/xua_test.c b/tests/xua/xua_test.c
index 77daa56..6096807 100644
--- a/tests/xua/xua_test.c
+++ b/tests/xua/xua_test.c
@@ -369,6 +369,9 @@
 #define PANDSIZ(x)	{ x, ARRAY_SIZE(x) }
 #define PARTU32(x, data)	{ .tag = x, .len = 4, .dat = (uint8_t *) data }
 #define PARTARR(x, data)	{ .tag = x, .len = ARRAY_SIZE(data), .dat = (uint8_t *) data }
+/* GCC-4 errors with 'initializer element is not constant' if using XUA_HDR
+ * inside a const struct (OS#5004) */
+#define _XUA_HDR(class, type)    { .spare = 0, .msg_class = (class), .msg_type = (type) }
 
 const uint32_t sua_proto_class0 = 0;
 const uint32_t sua_proto_class2 = 2;
@@ -384,7 +387,7 @@
 		.name = "BSSMAP-RESET",
 		.sccp = PANDSIZ(bssmap_reset),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
+			.hdr = _XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class0),
 				PARTARR(SUA_IEI_DEST_ADDR, sua_addr_ssn_bssmap),
@@ -395,7 +398,7 @@
 		.name = "BSSMAP-RESET-ACK",
 		.sccp = PANDSIZ(bssmap_reset_ack),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
+			.hdr = _XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class0),
 				PARTARR(SUA_IEI_DEST_ADDR, sua_addr_ssn_bssmap_pc1),
@@ -406,7 +409,7 @@
 		.name = "BSSMAP-PAGING",
 		.sccp = PANDSIZ(bssmap_paging),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
+			.hdr = _XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class0),
 				PARTARR(SUA_IEI_DEST_ADDR, sua_addr_ssn_bssmap_pc1),
@@ -417,7 +420,7 @@
 		.name = "BSSMAP-UDT",
 		.sccp = PANDSIZ(bssmap_udt),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
+			.hdr = _XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class0),
 				PARTARR(SUA_IEI_DEST_ADDR, sua_addr_ssn_bssmap),
@@ -428,7 +431,7 @@
 		.name = "BSSMAP-CR",
 		.sccp = PANDSIZ(bssmap_cr),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_CORE),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_CORE),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class2),
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_bsc),
@@ -439,7 +442,7 @@
 		.name = "BSSMAP-CC",
 		.sccp = PANDSIZ(bssmap_cc),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_COAK),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_COAK),
 			.parts = {
 				PARTU32(SUA_IEI_PROTO_CLASS, &sua_proto_class2),
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_msc),
@@ -450,7 +453,7 @@
 		.name = "BSSMAP-DTAP",
 		.sccp = PANDSIZ(bssmap_dtap),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_CODT),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_CODT),
 			.parts = {
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_msc),
 			},
@@ -459,7 +462,7 @@
 		.name = "BSSMAP-CLEAR",
 		.sccp = PANDSIZ(bssmap_clear),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_CODT),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_CODT),
 			.parts = {
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_msc),
 			},
@@ -468,7 +471,7 @@
 		.name = "BSSMAP-RELEASED",
 		.sccp = PANDSIZ(bssmap_released),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_RELRE),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_RELRE),
 			.parts = {
 				PARTU32(SUA_IEI_DEST_REF, &sua_loc_ref_msc),
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_bsc),
@@ -479,7 +482,7 @@
 		.name = "BSSMAP-RELEASE_COMPLETE",
 		.sccp = PANDSIZ(bssmap_release_complete),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CO, SUA_CO_RELCO),
+			.hdr = _XUA_HDR(SUA_MSGC_CO, SUA_CO_RELCO),
 			.parts = {
 				PARTU32(SUA_IEI_DEST_REF, &sua_loc_ref_bsc),
 				PARTU32(SUA_IEI_SRC_REF, &sua_loc_ref_msc),
@@ -489,7 +492,7 @@
 		.name = "TCAP",
 		.sccp = PANDSIZ(tcap_global_title),
 		.sua = {
-			.hdr = XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
+			.hdr = _XUA_HDR(SUA_MSGC_CL, SUA_CL_CLDT),
 			.parts = {
 			},
 		},

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/22629
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I890432ee976043d012b01023f7dd2cfecf79d115
Gerrit-Change-Number: 22629
Gerrit-PatchSet: 2
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210202/712f516d/attachment.htm>


More information about the gerrit-log mailing list