netlink.c:97: error: cast increases required alignment of target type
Rémi Denis-Courmont
remi at remlab.net
Mon Nov 9 10:03:48 PST 2009
Le lundi 9 novembre 2009 19:57:07 andrzej zaborowski, vous avez écrit :
> 2009/11/9 Rémi Denis-Courmont <remi at remlab.net>:
> > As far as I know NO extra alignement is needed. The kernel will anyway
> > memory copy from/to the sockaddr_pn buffer as part of the socket calls,
> > so it couldn't care less about alignment.
>
> Practically I'm sure you're right and maybe we should stick a (void *)
> cast in between the casts or disable the warning. Formally that
> memcpy is an implementation detail and could be true in one kernel
> version and false in the next version, so when you pass a struct
> sockaddr * to a function it should, in theory be aligned as such.
Well no. The only thing you're allowed to read from someone else's sockaddr is
the family field, which does have the same alignment in sockaddr_pn as in
sockaddr (practically, two bytes). After that, the reader is responsible for
casting back to the correct type.
So this warning is _bogus_.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the ofono
mailing list