I have been doing "make universe" for the first time in a long time and
I ran into an interesting one.
I had code that looked like:
    struct sockaddr_in *sin;
    struct addrinfo *res;

    - did a getaddrinfo() and then after this I had:
   ...
   sin = (struct sockaddr_in *)res->ai_addr;

For mips, it complained that the alignment requirement for "struct sockaddr_in"
is different than "struct sockaddr" related to the type cast.

I've worked around this by:
   struct sockaddr_in sin;
   ...
   memcpy(&sin, res->ai_addr, sizeof(sin));

Is this a real problem or a compiler quirk?

If it is real, it seems to me it would be nice if the alignment requirement for
"struct sockaddr" was the same as "struct sockaddr_in" and "struct 
sockaddr_in6".
Is there a "trick" that could be applied to "struct sockaddr" to force good 
alignment?

rick
_______________________________________________
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to