Change in libosmocore[master]: struct_endianess.py: also recognise unnamed substructs

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

neels gerrit-no-reply at lists.osmocom.org
Fri May 15 16:13:54 UTC 2020


neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/18256 )

Change subject: struct_endianess.py: also recognise unnamed substructs
......................................................................

struct_endianess.py: also recognise unnamed substructs

Before this, the new dtap_header substruct construct would end up being split
up in a weird way:

	struct dtap_header {
		uint8_t type;
		union {
			uint8_t link_id;  /* Backward compatibility */
			struct {
				uint8_t dlci_cc:2,
				dlci_spare:3,
				dlci_sapi:3; /* enum gsm0406_dlc_sapi */
			};
		};
		uint8_t length;
	} __attribute__((packed));

would previously become

	struct dtap_header {
		uint8_t type;
		union {
			uint8_t link_id;  /* Backward compatibility */
			struct {
	#if OSMO_IS_LITTLE_ENDIAN
				uint8_t dlci_cc:2,
				dlci_spare:3,
				dlci_sapi:3; /* enum gsm0406_dlc_sapi */
			};
		};
		uint8_t length;
	#elif OSMO_IS_BIG_ENDIAN
	/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
				uint8_t dlci_sapi:3, dlci_spare:3, dlci_cc:2;
			};
		};
		uint8_t length;
	#endif
	} __attribute__((packed));

now becomes

	struct dtap_header {
		uint8_t type;
		union {
			uint8_t link_id;  /* Backward compatibility */
			struct {
	#if OSMO_IS_LITTLE_ENDIAN
				uint8_t dlci_cc:2,
				dlci_spare:3,
				dlci_sapi:3; /* enum gsm0406_dlc_sapi */
	#elif OSMO_IS_BIG_ENDIAN
	/* auto-generated from the little endian part above (libosmocore/contrib/struct_endianess.py) */
				uint8_t dlci_sapi:3, dlci_spare:3, dlci_cc:2;
	#endif
			};
		};
		uint8_t length;
	} __attribute__((packed));

Change-Id: I3c4986ebd1e41aad8b279d6132b7e3b2539d7dc5
---
M contrib/struct_endianess.py
1 file changed, 3 insertions(+), 1 deletion(-)

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



diff --git a/contrib/struct_endianess.py b/contrib/struct_endianess.py
index be73fbe..6ce75fc 100755
--- a/contrib/struct_endianess.py
+++ b/contrib/struct_endianess.py
@@ -17,6 +17,7 @@
 
 re_substruct_start = re.compile(r'^\s+struct\s*{\s*$')
 re_substruct_end = re.compile(r'^\s+}\s*([^;]*\s)[a-zA-Z_][a-zA-Z_0-9]*\s*;\s*$')
+re_unnamed_substruct_end = re.compile(r'^\s+}\s*;\s*$')
 
 re_int_def = re.compile(r'(^\s*((const|unsigned|signed|char|int|long|int[0-9]+_t|uint[0-9]_t)\s+)+\s*)([^;]*;)',
                         re.DOTALL | re.MULTILINE)
@@ -73,7 +74,8 @@
         line = struct_body_lines[j]
 
         if (re_substruct_start.fullmatch(line)
-            or re_substruct_end.fullmatch(line)):
+            or re_substruct_end.fullmatch(line)
+            or re_unnamed_substruct_end.fullmatch(line)):
             end_def()
             arbitrary_part.append(line)
             j += 1

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I3c4986ebd1e41aad8b279d6132b7e3b2539d7dc5
Gerrit-Change-Number: 18256
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
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/20200515/dfce0ba6/attachment.htm>


More information about the gerrit-log mailing list