Cast alignment warnings

Russ Allbery rra at stanford.edu
Mon Aug 1 20:18:10 UTC 2011


Alexander Bartolich <alexander.bartolich at gmx.at> writes:

> Workarounds:
> - use union instead of casts
> - use getaddrinfo and getnameinfo

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.)

It does look like our definition of sockaddr_storage on systems where
there's an sa_len field is wrong, though.

#if !HAVE_STRUCT_SOCKADDR_STORAGE
# if HAVE_STRUCT_SOCKADDR_SA_LEN
struct sockaddr_storage {
    unsigned char ss_len;
    unsigned char ss_family;
    unsigned char __padding[128 - 2];
};
# else
struct sockaddr_storage {
    unsigned short ss_family;
    unsigned char __padding[128 - 2];
};
# endif
#endif

There's even a comment saying that this doesn't implement the alignment
goo properly.  I'm not sure how much it matters, given how ubiquitous
support for those functions now is, but RFC 3493 has the correct struct
definitions, I think.

-- 
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