netlink.c:97: error: cast increases required alignment of target type

Rémi Denis-Courmont remi at remlab.net
Mon Nov 9 09:45:53 PST 2009


Le lundi 9 novembre 2009 19:34:36 andrzej zaborowski, vous avez écrit :
> 2009/11/9 Rémi Denis-Courmont <remi at remlab.net>:
> > Le lundi 9 novembre 2009 17:45:25 andrzej zaborowski, vous avez écrit :
> >> Hi,
> >> resurrecting this thread because I think there's no reason ofono
> >> should not build on cpus with strict alignment rules, the netlink code
> >> is actually aligned correctly.  These warnings are a result of
> >> -Wcast-align, the compiler can't know that the casts in the macros are
> >> safe, but they obviously are if you look at the arithmetics there.  In
> >> the case of the netlink warnings they can be turned off for all users
> >> of <linux/netlink.h> using a pragma or only for this cast by casting
> >> to void * first (the only way according to gcc people), the first
> >> attached file adds them (against linux), I'll send it to linux if
> >> there's no better idea.  There are also similar warnings when casting
> >> struct sockaddr_pn * to struct sockaddr * and these can be worked
> >> around in ofono, see second patch, but probably should also be in
> >> linux's include/linux/phonet.h instead.
> >
> > Why do you change the sockaddr_pn type name?!
> 
> Because it's been defined without explicit alignment and I don't think
> you can redefine it with the same name?

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.

-- 
Rémi Denis-Courmont
http://www.remlab.net/


More information about the ofono mailing list