dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35212?usp=email )
Change subject: ecu: force alignment of member data in struct osmo_ecu_state ......................................................................
ecu: force alignment of member data in struct osmo_ecu_state
The member data[0] in struct osmo_ecu_state is used as an anchor to attach private structs for a concrete ECU implementation. This works by allocating more memory then struct osmo_ecu_state actually needs and then using the excess memory to store the private struct of the concrete ECU implementation.
However, thsi poses a problem since data[0] is at the end of the struct it may land in an unaligned position. This also means that the struct we store there is also unaligned. We should fix this by ensuring that data[0] lands at an aligned memory location.
Related: OS#6286 Change-Id: I28672856e8e8f47e04ffe09ee3e07b577108cdc7 --- M include/osmocom/codec/ecu.h 1 file changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/12/35212/1
diff --git a/include/osmocom/codec/ecu.h b/include/osmocom/codec/ecu.h index 6492860..7750540 100644 --- a/include/osmocom/codec/ecu.h +++ b/include/osmocom/codec/ecu.h @@ -46,6 +46,7 @@ /* Codec independent ECU state */ struct osmo_ecu_state { enum osmo_ecu_codec codec; + struct {} __attribute__ ((aligned)); uint8_t data[0]; };