Re: [libvirt] broken OpenBSD net/if.h [was: [PATCH] Include some extra headers needed for OpenBSD.]
On Tue, Sep 04, 2012 at 11:37:30AM -0600, Eric Blake wrote: On 09/04/2012 11:23 AM, Jasper Lievisse Adriaanse wrote: On Tue, Sep 04, 2012 at 11:08:30AM -0600, Eric Blake wrote: [adding gnulib] Ouch. The POSIX definition of net/if.h doesn't include any interface that needs to use struct sockaddr. Which OpenBSD extension function is triggering this warning? According to POSIX, this .c file should compile: #define _POSIX_C_SOURCE 200809L #include net/if.h #include sys/socket.h struct if_nameindex i; That snippet of example code does not compile on OpenBSD: In file included from foo.c:2: /usr/include/net/if.h:112: error: expected specifier-qualifier-list before 'u_int' Could you please reference where POSIX states it should, so this can hopefully get fixed in OpenBSD. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html#tag_13_30 doesn't mention any prerequisite headers for net/if.h. Furthermore, looking at each of the functions in that header, none of them call out a prerequisite: http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_freenameindex.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_indextoname.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nameindex.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nametoindex.html# If a header cannot be used in isolation, then POSIX would call out multiple headers. For comparison, here's a case where POSIX 2008 _does_ call out multiple headers: http://pubs.opengroup.org/onlinepubs/9699919799/functions/creat.html creat() cannot use the S_IRUSR and other constants for its mode_t argument unless you also include sys/stat.h, since fcntl.h was not required to be self-contained on that front (there's talk underway about getting that fixed in the next version of POSIX, but that's another story... http://austingroupbugs.net/view.php?id=591) -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org A diff for the OpenBSD header file has been created and is currently being tested. So this should be fixed pretty soon (and in time for OpenBSD 5.3). -- Cheers, Jasper Stay Hungry. Stay Foolish -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] broken OpenBSD net/if.h [was: [PATCH] Include some extra headers needed for OpenBSD.]
On 09/04/2012 11:23 AM, Jasper Lievisse Adriaanse wrote: On Tue, Sep 04, 2012 at 11:08:30AM -0600, Eric Blake wrote: [adding gnulib] Ouch. The POSIX definition of net/if.h doesn't include any interface that needs to use struct sockaddr. Which OpenBSD extension function is triggering this warning? According to POSIX, this .c file should compile: #define _POSIX_C_SOURCE 200809L #include net/if.h #include sys/socket.h struct if_nameindex i; It turns out that FreeBSD 8.2 also has a non-self-contained net/if.h; so even though I don't have an OpenBSD box handy today, I was able to test a module for a replacement header that works around the issue. Patch coming up shortly. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] broken OpenBSD net/if.h [was: [PATCH] Include some extra headers needed for OpenBSD.]
[adding gnulib] On 09/04/2012 10:52 AM, Jasper Lievisse Adriaanse wrote: I'd still like to know the compiler error you got when sys/socket.h was not present, but just guessing from the source code, I see one call of socket() (protected behind #if defined(HAVE_NET_IF_H) defined(SIOCBRADDBR), but maybe those are both true for OpenBSD?). Even though I'm pushing, I would STILL like to know why. Of course, here it is: In file included from util/virnetdevbridge.c:35: /usr/include/net/if.h:276: warning: 'struct sockaddr' declared inside parameter list Ouch. The POSIX definition of net/if.h doesn't include any interface that needs to use struct sockaddr. Which OpenBSD extension function is triggering this warning? According to POSIX, this .c file should compile: #define _POSIX_C_SOURCE 200809L #include net/if.h #include sys/socket.h struct if_nameindex i; and it might just compile on OpenBSD (I haven't checked myself); the difference is that we have explicitly asked for namespace pollution beyond what _POSIX_C_SOURCE guarantees, which may explain why 'struct sockaddr' is interfering. But since net/if.h is required to be self-contained when in a strict environment, it makes sense for it to also be self-contained in an extension environment. It sounds like gnulib should consider providing a replacement net/if.h function to work around this lameness. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] broken OpenBSD net/if.h [was: [PATCH] Include some extra headers needed for OpenBSD.]
On Tue, Sep 04, 2012 at 11:08:30AM -0600, Eric Blake wrote: [adding gnulib] On 09/04/2012 10:52 AM, Jasper Lievisse Adriaanse wrote: I'd still like to know the compiler error you got when sys/socket.h was not present, but just guessing from the source code, I see one call of socket() (protected behind #if defined(HAVE_NET_IF_H) defined(SIOCBRADDBR), but maybe those are both true for OpenBSD?). Even though I'm pushing, I would STILL like to know why. Of course, here it is: In file included from util/virnetdevbridge.c:35: /usr/include/net/if.h:276: warning: 'struct sockaddr' declared inside parameter list Ouch. The POSIX definition of net/if.h doesn't include any interface that needs to use struct sockaddr. Which OpenBSD extension function is triggering this warning? According to POSIX, this .c file should compile: #define _POSIX_C_SOURCE 200809L #include net/if.h #include sys/socket.h struct if_nameindex i; and it might just compile on OpenBSD (I haven't checked myself); the difference is that we have explicitly asked for namespace pollution beyond what _POSIX_C_SOURCE guarantees, which may explain why 'struct sockaddr' is interfering. But since net/if.h is required to be self-contained when in a strict environment, it makes sense for it to also be self-contained in an extension environment. It sounds like gnulib should consider providing a replacement net/if.h function to work around this lameness. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org That snippet of example code does not compile on OpenBSD: In file included from foo.c:2: /usr/include/net/if.h:112: error: expected specifier-qualifier-list before 'u_int' /usr/include/net/if.h:125: error: expected specifier-qualifier-list before 'u_char' /usr/include/net/if.h:188: error: expected specifier-qualifier-list before 'u_char' /usr/include/net/if.h:262: error: expected specifier-qualifier-list before 'u_short' /usr/include/net/if.h:474: error: expected specifier-qualifier-list before 'u_int' /usr/include/net/if.h:485: error: expected specifier-qualifier-list before 'u_int' /usr/include/net/if.h:493: error: expected specifier-qualifier-list before 'u_short' /usr/include/net/if.h:512: error: expected specifier-qualifier-list before 'u_short' /usr/include/net/if.h:530: error: expected specifier-qualifier-list before 'u_short' /usr/include/net/if.h:551: error: expected specifier-qualifier-list before 'u_int' /usr/include/net/if.h:586: error: expected specifier-qualifier-list before 'u_int' /usr/include/net/if.h:606: error: field 'ifru_addr' has incomplete type /usr/include/net/if.h:607: error: field 'ifru_dstaddr' has incomplete type /usr/include/net/if.h:608: error: field 'ifru_broadaddr' has incomplete type /usr/include/net/if.h:626: error: field 'ifra_addr' has incomplete type /usr/include/net/if.h:627: error: field 'ifra_dstaddr' has incomplete type /usr/include/net/if.h:629: error: field 'ifra_mask' has incomplete type /usr/include/net/if.h:673: error: field 'addr' has incomplete type /usr/include/net/if.h:674: error: field 'dstaddr' has incomplete type In file included from /usr/include/net/if.h:691, from foo.c:2: /usr/include/net/if_arp.h:79: error: field 'arp_pa' has incomplete type /usr/include/net/if_arp.h:80: error: field 'arp_ha' has incomplete type *** Error code 1 Could you please reference where POSIX states it should, so this can hopefully get fixed in OpenBSD. -- Cheers, Jasper Stay Hungry. Stay Foolish -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] broken OpenBSD net/if.h [was: [PATCH] Include some extra headers needed for OpenBSD.]
On 09/04/2012 11:23 AM, Jasper Lievisse Adriaanse wrote: On Tue, Sep 04, 2012 at 11:08:30AM -0600, Eric Blake wrote: [adding gnulib] Ouch. The POSIX definition of net/if.h doesn't include any interface that needs to use struct sockaddr. Which OpenBSD extension function is triggering this warning? According to POSIX, this .c file should compile: #define _POSIX_C_SOURCE 200809L #include net/if.h #include sys/socket.h struct if_nameindex i; That snippet of example code does not compile on OpenBSD: In file included from foo.c:2: /usr/include/net/if.h:112: error: expected specifier-qualifier-list before 'u_int' Could you please reference where POSIX states it should, so this can hopefully get fixed in OpenBSD. http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html#tag_13_30 doesn't mention any prerequisite headers for net/if.h. Furthermore, looking at each of the functions in that header, none of them call out a prerequisite: http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_freenameindex.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_indextoname.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nameindex.html# http://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nametoindex.html# If a header cannot be used in isolation, then POSIX would call out multiple headers. For comparison, here's a case where POSIX 2008 _does_ call out multiple headers: http://pubs.opengroup.org/onlinepubs/9699919799/functions/creat.html creat() cannot use the S_IRUSR and other constants for its mode_t argument unless you also include sys/stat.h, since fcntl.h was not required to be self-contained on that front (there's talk underway about getting that fixed in the next version of POSIX, but that's another story... http://austingroupbugs.net/view.php?id=591) -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list