[Dnsmasq-discuss] [PATCH] Fix alignment issue

Alex Landau landau_alex at yahoo.com
Tue Aug 7 07:46:23 BST 2007


--- Simon Kelley <simon at thekelleys.org.uk> wrote:

> 
> Thanks to Alex for finding and diagnosing this problem. My first
> reaction was that it's a compiler problem: gcc shouldn't replace the
> (alignment safe) memcpy with  a straight register copy. However, that's
> wrong. It turns out that if you cast a pointer to <pointer to foo> which
> isn't aligned for <foo> then the results are undefined.
> 
> http://lists.debian.org/debian-gcc/2005/08/msg00412.html
> 
> has details, including C-standard reference. So gcc is completely
> entitled to assume that a struct all_addr * is properly aligned.

That's what I thought (I couldn't believe gcc is _that_ broken), but didn't find a
reference.

> 
> When I looked, there's an even more egregious problem where the same
> pointer is just dereferenced in dns_doctor().
> 
> Given that the problem is my bad C, I think the best solution is to fix
> that, rather than patch it up with compiler directives. I've put up a
> test release at
> 
> http://www.thekelleys.org.uk/dnsmasq/test-releases/dnsmasq-2.40test20.tar.gz
> 
> which I think fixes things. Alex, I'd appreciate it if you could check
> that on your Blackfin box. There are no changes from rc1, apart from the
> alignment fix.
> 

Works fine, thanks!

A few compilation warnings, if you're interested... They were present in the previous
version too.

bfin-uclinux-gcc -O2 -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ -DNO_GETTEXT
`echo -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ | ../bld/pkg-wrapper pkg-config
--cflags dbus-1`  -Wall -W -c rfc1035.c
rfc1035.c: In function ‘questions_crc’:
rfc1035.c:352: warning: comparison between signed and unsigned
rfc1035.c: In function ‘find_pseudoheader’:
rfc1035.c:429: warning: comparison between signed and unsigned
rfc1035.c: In function ‘find_soa’:
rfc1035.c:512: warning: comparison between signed and unsigned
rfc1035.c:548: warning: comparison between signed and unsigned
rfc1035.c: In function ‘extract_addresses’:
rfc1035.c:609: warning: comparison between signed and unsigned
rfc1035.c:640: warning: comparison between signed and unsigned
rfc1035.c:715: warning: comparison between signed and unsigned
rfc1035.c: In function ‘check_for_bogus_wildcard’:
rfc1035.c:920: warning: comparison between signed and unsigned

bfin-uclinux-gcc -O2 -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ -DNO_GETTEXT
`echo -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ | ../bld/pkg-wrapper pkg-config
--cflags dbus-1`  -Wall -W -c dnsmasq.c
dnsmasq.c: In function ‘check_dns_listeners’:
dnsmasq.c:848: warning: unused variable ‘p’

bfin-uclinux-gcc -O2 -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ -DNO_GETTEXT
`echo -DNO_IPV6 -DNO_TFTP -DHAVE_BROKEN_RTC -D__uClinux__ | ../bld/pkg-wrapper pkg-config
--cflags dbus-1`  -Wall -W -c netlink.c
netlink.c: In function ‘iface_enumerate’:
netlink.c:122: warning: label ‘again’ defined but not used
netlink.c:104: warning: unused parameter ‘ipv6_callback’

> 
> Cheers,
> 
> Simon.

Thanks,
Alex


       
____________________________________________________________________________________
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more. 
http://mobile.yahoo.com/go?refer=1GNXIC



More information about the Dnsmasq-discuss mailing list