GNOME Bugzilla – Bug 336390
Incorrect use of the IN6_ARE_ADDR_EQUAL macro
Last modified: 2006-03-28 20:17:54 UTC
The libgnomevfs/gnome-vfs-address.c file uses the IN6_ARE_ADDR_EQUAL macro in a way that only works in Linux, thus breaking the build in, e.g., NetBSD or Solaris. The problem is that the call messes with in6_addr internals by accessing their s6_addr field, which in several platforms is "mapped" to an array, not a structure. Consider the following test program, which mimics gnome-vfs-address.c's way of calling the offending macro: #include <stdio.h> #include <netinet/in.h> int main(void) { const struct sockaddr_in6 *a = NULL; const struct sockaddr_in6 *b = NULL; return IN6_ARE_ADDR_EQUAL(a->sin6_addr.s6_addr, b->sin6_addr.s6_addr); } Building this test case in NetBSD gives: test.c: In function `main': test.c:10: error: request for member `__u6_addr' in something not a structure or union test.c:10: error: request for member `__u6_addr' in something not a structure or union Building this test case in Solaris gives: test.c: In function `main': test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union test.c:10: error: request for member `_S6_un' in something not a structure or union Building it in Linux works, though. In order to fix this, the code should pass the in6_addr structure to the macro, not one of its fields, and let the macro take appropriate action. I.e., the code above could say &a->sin6_addr instead of a->sin6_addr.s6_addr. After applying the attached patch, the affected file builds in NetBSD, Solaris and, of course, Linux.
Created attachment 62238 [details] [review] Proposed patch.
For what is worth modules/http-method.c and modules/http-proxy.c use the macro appropriately. (Just discovered it.)
Looks fine to me. Go ahead and commit it!
Sorry, I do not have commit access. Someone else will have to do it ;-)
Commited! Thanks a lot!