Cast alignment warnings
Russ Allbery
rra at stanford.edu
Mon Aug 1 20:51:05 UTC 2011
Julien ÉLIE <julien at trigofacile.com> writes:
> Hi Russ,
>> INN already uses getaddrinfo and getnameinfo almost everywhere, but
>> that doesn't actually help all that much unless one only passes around
>> addrinfo structs instead of sockaddrs, and that's kind of awkward when
>> getpeername returns a sockaddr. (Also, you'll notice that some of the
>> warnings are from INN's replacement for a missing getaddrinfo and
>> getnameinfo.)
> These specific two warnings came from the test suite.
They're from the replacement code in lib, which is only built by the test
suite since your libc has its own implementations of getnameinfo and
getaddrinfo. They're from code patterns like:
ai->ai_addr = malloc(sizeof(struct sockaddr_in));
/* ... */
((struct sockaddr_in *) ai->ai_addr)->sin_family = AF_INET;
((struct sockaddr_in *) ai->ai_addr)->sin_addr = addr;
((struct sockaddr_in *) ai->ai_addr)->sin_port = htons(port);
One could avoid the warning by introducing a temporary variable, I
suppose, but the code is valid and won't have alignment problems.
> At least, on this sparc64, the replacement code is not used for the main
> INN binaries.
> include/config.h:#define HAVE_STRUCT_SOCKADDR_STORAGE 1
> include/config.h:#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1
Yeah, it won't be used on any OS with IPv6 support.
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
Please send questions to the list rather than mailing me directly.
<http://www.eyrie.org/~eagle/faqs/questions.html> explains why.
More information about the inn-workers
mailing list