laforge has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmocore/+/35156?usp=email )

Change subject: Fix union abis_rsl_chan_nr and abis_rsl_link_id
......................................................................

Fix union abis_rsl_chan_nr and abis_rsl_link_id

All bit fields in a union will overlap in memory, as all elements in a
union do. To prevent the bit fields from overlapping, wrap them into a
packed structure.

Change-Id: I5ef5aa62be8310da4ebe9ea73ebbedcbcc2ba49c
---
M include/osmocom/gsm/protocol/gsm_08_58.h
1 file changed, 19 insertions(+), 2 deletions(-)

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




diff --git a/include/osmocom/gsm/protocol/gsm_08_58.h 
b/include/osmocom/gsm/protocol/gsm_08_58.h
index 0a44db9..e8758df 100644
--- a/include/osmocom/gsm/protocol/gsm_08_58.h
+++ b/include/osmocom/gsm/protocol/gsm_08_58.h
@@ -29,6 +29,7 @@

 /* Channel Number 9.3.1 */
 union abis_rsl_chan_nr {
+       struct {
 #if OSMO_IS_BIG_ENDIAN
                uint8_t cbits:5,
                        tn:3;
@@ -36,7 +37,8 @@
                uint8_t tn:3,
                        cbits:5;
 #endif
-               uint8_t chan_nr;
+       } __attribute__ ((packed));
+       uint8_t chan_nr;
 } __attribute__ ((packed));
 #define ABIS_RSL_CHAN_NR_CBITS_Bm_ACCHs        0x01
 #define ABIS_RSL_CHAN_NR_CBITS_Lm_ACCHs(ss)    (0x02 + (ss))
@@ -55,6 +57,7 @@

 /* Link Identifier 9.3.2 */
 union abis_rsl_link_id {
+       struct {
 #if OSMO_IS_BIG_ENDIAN
                uint8_t cbits:2,
                        na:1,
@@ -66,7 +69,8 @@
                        na:1,
                        cbits:2;
 #endif
-               uint8_t link_id;
+       } __attribute__ ((packed));
+       uint8_t link_id;
 } __attribute__ ((packed));
 #define ABIS_RSL_LINK_ID_CBITS_FACCH_SDCCH 0x00
 #define ABIS_RSL_LINK_ID_CBITS_SACCH 0x01

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35156?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5ef5aa62be8310da4ebe9ea73ebbedcbcc2ba49c
Gerrit-Change-Number: 35156
Gerrit-PatchSet: 2
Gerrit-Owner: jolly <andr...@eversberg.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de>
Gerrit-Reviewer: laforge <lafo...@osmocom.org>
Gerrit-MessageType: merged

Reply via email to