Hi Brian,
>> (...)
>> ell/util.h:40:3: error: cast increases required alignment of target type
[-Werror=cast-align]
>> (type *)((char *) __mptr - offsetof(type, member)); \
>> ^
>> ell/dbus.c:582:3: note: in expansion of macro ‘l_container_of’
>> l_container_of(dbus, struct l_dbus_classic, super);
>> ^~~~~~~~~~~~~~
>
> FWIW, I've encountered that on iMX.6 as well. I've fixed that with:
>
> diff --git a/ell/util.h b/ell/util.h
> index 4f20ef0..fe7c7e2 100644
> --- a/ell/util.h
> +++ b/ell/util.h
> @@ -37,7 +37,7 @@ extern "C" {
>
> #define l_container_of(ptr, type, member) ({ \
> const __typeof__(((type *) 0)->member) *__mptr = (ptr); \
> - (type *)((char *) __mptr - offsetof(type, member)); \
> + (type *)(void *)((char *) __mptr - offsetof(type, member)); \
> })
Any opinion on this change? It is causing us build fails on some platforms (including
Raspberry PI 4).
I have not yet had a chance to run the battery of unit tests with this change in ELL, and
am not even really
sure of the if this warning means that there could be some unforseen impact.
Otherwise, perhaps we should just create an ELL patch that makes clears up these warnings
(Michał?).
If this is done, we should make sure it gets all of them, and not just the dbus.c
instances.
I am fine with this patch, but I am also not the expert in memory layout of structs for
different architectures. So if we do not encounter issues on x86 and ARM (I will test
PowerPC later) then I am fine with changing this.
Regards
Marcel