OoO Peu avant le début de l'après-midi du samedi 07 mars 2009, vers 13:03, je disais: > lldpd, a program of my own, available on https://trac.luffy.cx/lldpd/ ;, [...] Hi again! I have another alignment problem on ARM (still not related to Debian). Since I did get valuable help here last year, I try again. :) This time, a user of mine is getting this message when compiling: interfaces.c: In function `iface_minimal_checks': interfaces.c:421: warning: cast increases required alignment of target type The corresponding code is : static int iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) { struct sockaddr_ll *sdl; [...] sdl = (struct sockaddr_ll *)ifa->ifa_addr; if (sdl->sll_hatype != ARPHRD_ETHER || !sdl->sll_halen) return 0; [...] } ifa->ifa_addr is "struct sockaddr" and I can understand that the alignment may be less than "struct sockaddr_ll". For example, if my "struct sockaddr" is 8-bit aligned but not 16-bit aligned, then when I try to use it as "struct sockaddr_ll" which requires to be 16-bit aligned, I get an unaligned access. I could use a memcpy but I think this is not the right way. The user reporting the error is using some old uclibc which does not define getifaddrs() nor struct ifaddrs. Therefore, I have reimplemented getifaddrs() and I declare struct ifaddrs as it appears in /usr/include/ifaddrs.h (using struct sockaddr for ifa_addr). I see that there is some internal datatype called struct sockaddr_storage that tries to deal with alignment issues. Is it the key to my problem? I have also warnings in my (stolen) implementation of getifaddrs(). My getifaddrs() implementation: http://cgit.luffy.cx/lldpd/tree/src/getifaddrs.c My struct ifaddrs declaration: http://cgit.luffy.cx/lldpd/tree/src/compat.h#n146 The location of the warning: http://cgit.luffy.cx/lldpd/tree/src/interfaces.c#n421 Crosspost to my address would be appreciated. Thanks for any help on this! -- BOFH excuse #209: Only people with names beginning with 'A' are getting mail this week (a la Microsoft)
Attachment:
pgpJC0MoKJIA1.pgp
Description: PGP signature