Neels Hofmeyr has posted comments on this change. ( https://gerrit.osmocom.org/11787 )
Change subject: add/clean big-endian packed structs (struct_endianess.py) ...................................................................... Patch Set 3: (2 comments) https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h File include/osmocom/gprs/protocol/gsm_04_60.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gprs/protocol/gsm_04_60.h@33 PS2, Line 33: uint8_t tfi_hi:2, cv:4, si:1, r:1; > Please change the script to add lines/formatting like in the little endian > case. that's "impossible" since the order is reversed. Doing it the tivial way it usually is done so far with whitespace carried along in the regexes, it would end up as: uint8_t tfi_hi:8; cv:4, si:1, r:1, (sic) and I'm positively not going to spend time on that: it would involve interpreting indenting levels and open a whole nother chapter of pseudo intelligence. I actually also prefer the packed output in the big-endian section, so no matter what formatting the original author invented, the big-endian part is "one line per byte" and more compact; whitespace changes then (mostly) don't affect the big-endian part. To read the struct for human understanding, just read above. https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h File include/osmocom/gsm/protocol/gsm_03_41.h: https://gerrit.osmocom.org/#/c/11787/2/include/osmocom/gsm/protocol/gsm_03_41.h@36 PS2, Line 36: uint8_t language:4; > Be careful here!! […] no, the struct is packed. They are both a single byte. If you want to have ignored bits, you need to add 'padding' members. (but you had me for a second there) try this: cat > /tmp/x.c <<END struct foo { unsigned int a:4; unsigned int b:4; } __attribute__((packed)); int main(void) { return sizeof(struct foo); } END make -C /tmp x /tmp/x; echo $? prints 1, i.e. struct foo is one byte. -- To view, visit https://gerrit.osmocom.org/11787 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: Ia0b99d76932aeb03e93bd0c62d3bf025dec5f9d2 Gerrit-Change-Number: 11787 Gerrit-PatchSet: 3 Gerrit-Owner: Neels Hofmeyr <[email protected]> Gerrit-Reviewer: Jenkins Builder (1000002) Gerrit-Reviewer: Neels Hofmeyr <[email protected]> Gerrit-Reviewer: Pau Espin Pedrol <[email protected]> Gerrit-Comment-Date: Mon, 19 Nov 2018 16:09:52 +0000 Gerrit-HasComments: Yes Gerrit-HasLabels: No
