[libvirt] broken OpenBSD <net/if.h> [was: [PATCH] Include some extra headers needed for OpenBSD.]

Eric Blake eblake at redhat.com
Tue Sep 4 17:08:30 UTC 2012


[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   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120904/823c519a/attachment-0001.sig>


More information about the libvir-list mailing list