qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] io: fix build on FreeBSD
@ 2016-02-25 15:31 Ed Maste
  2016-02-25 15:46 ` Daniel P. Berrange
  2016-02-25 16:29 ` Eric Blake
  0 siblings, 2 replies; 7+ messages in thread
From: Ed Maste @ 2016-02-25 15:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: Ed Maste

EAI_ADDRFAMILY is obsolete and FreeBSD/s netdb.h does not provide a
definition.

Signed-off-by: Ed Maste <emaste@freebsd.org>
---
 tests/test-io-channel-socket.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
index 0697363..f4dbd60 100644
--- a/tests/test-io-channel-socket.c
+++ b/tests/test-io-channel-socket.c
@@ -63,7 +63,10 @@ static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
 
     gaierr = getaddrinfo("::1", NULL, &hints, &ai);
     if (gaierr != 0) {
-        if (gaierr == EAI_ADDRFAMILY ||
+        if (
+#ifdef EAI_ADDRFAMILY
+            gaierr == EAI_ADDRFAMILY ||
+#endif
             gaierr == EAI_FAMILY ||
             gaierr == EAI_NONAME) {
             *has_ipv6 = false;
-- 
2.4.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 15:31 [Qemu-devel] [PATCH] io: fix build on FreeBSD Ed Maste
@ 2016-02-25 15:46 ` Daniel P. Berrange
  2016-02-25 16:29 ` Eric Blake
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel P. Berrange @ 2016-02-25 15:46 UTC (permalink / raw)
  To: Ed Maste, qemu-trivial; +Cc: qemu-devel

On Thu, Feb 25, 2016 at 10:31:32AM -0500, Ed Maste wrote:
> EAI_ADDRFAMILY is obsolete and FreeBSD/s netdb.h does not provide a
> definition.
> 
> Signed-off-by: Ed Maste <emaste@freebsd.org>
> ---
>  tests/test-io-channel-socket.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>

Copying qemu-trivial to pick up the patch

> 
> diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
> index 0697363..f4dbd60 100644
> --- a/tests/test-io-channel-socket.c
> +++ b/tests/test-io-channel-socket.c
> @@ -63,7 +63,10 @@ static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
>  
>      gaierr = getaddrinfo("::1", NULL, &hints, &ai);
>      if (gaierr != 0) {
> -        if (gaierr == EAI_ADDRFAMILY ||
> +        if (
> +#ifdef EAI_ADDRFAMILY
> +            gaierr == EAI_ADDRFAMILY ||
> +#endif
>              gaierr == EAI_FAMILY ||
>              gaierr == EAI_NONAME) {
>              *has_ipv6 = false;
> -- 
> 2.4.6
> 

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 15:31 [Qemu-devel] [PATCH] io: fix build on FreeBSD Ed Maste
  2016-02-25 15:46 ` Daniel P. Berrange
@ 2016-02-25 16:29 ` Eric Blake
  2016-02-25 16:32   ` Daniel P. Berrange
  1 sibling, 1 reply; 7+ messages in thread
From: Eric Blake @ 2016-02-25 16:29 UTC (permalink / raw)
  To: Ed Maste, qemu-devel, Daniel P. Berrange

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On 02/25/2016 08:31 AM, Ed Maste wrote:
> EAI_ADDRFAMILY is obsolete and FreeBSD/s netdb.h does not provide a
> definition.
> 
> Signed-off-by: Ed Maste <emaste@freebsd.org>
> ---
>  tests/test-io-channel-socket.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
> index 0697363..f4dbd60 100644
> --- a/tests/test-io-channel-socket.c
> +++ b/tests/test-io-channel-socket.c
> @@ -63,7 +63,10 @@ static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
>  
>      gaierr = getaddrinfo("::1", NULL, &hints, &ai);
>      if (gaierr != 0) {
> -        if (gaierr == EAI_ADDRFAMILY ||
> +        if (
> +#ifdef EAI_ADDRFAMILY
> +            gaierr == EAI_ADDRFAMILY ||
> +#endif
>              gaierr == EAI_FAMILY ||

I'm not the biggest-fan of mid-expression #ifdefs. Can we rewrite this
to look more like:

#ifndef EAI_ADDRFAMILY
#define EAI_ADDRFAMILY EAI_FAMILY
#endif

and leave the conditional expression unchanged?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 16:29 ` Eric Blake
@ 2016-02-25 16:32   ` Daniel P. Berrange
  2016-02-25 16:37     ` Eric Blake
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel P. Berrange @ 2016-02-25 16:32 UTC (permalink / raw)
  To: Eric Blake; +Cc: Ed Maste, qemu-devel

On Thu, Feb 25, 2016 at 09:29:02AM -0700, Eric Blake wrote:
> On 02/25/2016 08:31 AM, Ed Maste wrote:
> > EAI_ADDRFAMILY is obsolete and FreeBSD/s netdb.h does not provide a
> > definition.
> > 
> > Signed-off-by: Ed Maste <emaste@freebsd.org>
> > ---
> >  tests/test-io-channel-socket.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tests/test-io-channel-socket.c b/tests/test-io-channel-socket.c
> > index 0697363..f4dbd60 100644
> > --- a/tests/test-io-channel-socket.c
> > +++ b/tests/test-io-channel-socket.c
> > @@ -63,7 +63,10 @@ static int check_protocol_support(bool *has_ipv4, bool *has_ipv6)
> >  
> >      gaierr = getaddrinfo("::1", NULL, &hints, &ai);
> >      if (gaierr != 0) {
> > -        if (gaierr == EAI_ADDRFAMILY ||
> > +        if (
> > +#ifdef EAI_ADDRFAMILY
> > +            gaierr == EAI_ADDRFAMILY ||
> > +#endif
> >              gaierr == EAI_FAMILY ||
> 
> I'm not the biggest-fan of mid-expression #ifdefs. Can we rewrite this
> to look more like:
> 
> #ifndef EAI_ADDRFAMILY
> #define EAI_ADDRFAMILY EAI_FAMILY
> #endif
> 
> and leave the conditional expression unchanged?

I think that'll cause gcc  6 to whine about you checking the same
value twice in the conditional, like how it complains that EWOULDBLOCK
and EAGAIN are the same.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 16:32   ` Daniel P. Berrange
@ 2016-02-25 16:37     ` Eric Blake
  2016-02-25 16:41       ` Daniel P. Berrange
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2016-02-25 16:37 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Ed Maste, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

On 02/25/2016 09:32 AM, Daniel P. Berrange wrote:

>>> +        if (
>>> +#ifdef EAI_ADDRFAMILY
>>> +            gaierr == EAI_ADDRFAMILY ||
>>> +#endif
>>>              gaierr == EAI_FAMILY ||
>>
>> I'm not the biggest-fan of mid-expression #ifdefs. Can we rewrite this
>> to look more like:
>>
>> #ifndef EAI_ADDRFAMILY
>> #define EAI_ADDRFAMILY EAI_FAMILY
>> #endif
>>
>> and leave the conditional expression unchanged?
> 
> I think that'll cause gcc  6 to whine about you checking the same
> value twice in the conditional, like how it complains that EWOULDBLOCK
> and EAGAIN are the same.

Oh, right. That's annoying.  What about:

#ifndef EAI_ADDRFAMILY
#define EAI_ADDRFAMILY 0
#endif

if ((EAI_ADDRFAMILY && gaierr == EAIADDRFAMILY) ||
    gaierr == EAI_FAMILY...

to shut up gcc 6, while still hoisting the preprocessor logic outside of
the expression?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 16:37     ` Eric Blake
@ 2016-02-25 16:41       ` Daniel P. Berrange
  2016-02-26 14:25         ` Ed Maste
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel P. Berrange @ 2016-02-25 16:41 UTC (permalink / raw)
  To: Eric Blake; +Cc: Ed Maste, qemu-devel

On Thu, Feb 25, 2016 at 09:37:18AM -0700, Eric Blake wrote:
> On 02/25/2016 09:32 AM, Daniel P. Berrange wrote:
> 
> >>> +        if (
> >>> +#ifdef EAI_ADDRFAMILY
> >>> +            gaierr == EAI_ADDRFAMILY ||
> >>> +#endif
> >>>              gaierr == EAI_FAMILY ||
> >>
> >> I'm not the biggest-fan of mid-expression #ifdefs. Can we rewrite this
> >> to look more like:
> >>
> >> #ifndef EAI_ADDRFAMILY
> >> #define EAI_ADDRFAMILY EAI_FAMILY
> >> #endif
> >>
> >> and leave the conditional expression unchanged?
> > 
> > I think that'll cause gcc  6 to whine about you checking the same
> > value twice in the conditional, like how it complains that EWOULDBLOCK
> > and EAGAIN are the same.
> 
> Oh, right. That's annoying.  What about:
> 
> #ifndef EAI_ADDRFAMILY
> #define EAI_ADDRFAMILY 0
> #endif
> 
> if ((EAI_ADDRFAMILY && gaierr == EAIADDRFAMILY) ||
>     gaierr == EAI_FAMILY...
> 
> to shut up gcc 6, while still hoisting the preprocessor logic outside of
> the expression?

To be honest, I think the preprocessor check inside the expression isn't
a big deal and clearer than playing games like this.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] io: fix build on FreeBSD
  2016-02-25 16:41       ` Daniel P. Berrange
@ 2016-02-26 14:25         ` Ed Maste
  0 siblings, 0 replies; 7+ messages in thread
From: Ed Maste @ 2016-02-26 14:25 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel

On 25 February 2016 at 11:41, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Thu, Feb 25, 2016 at 09:37:18AM -0700, Eric Blake wrote:
>>
>> Oh, right. That's annoying.  What about:
>>
>> #ifndef EAI_ADDRFAMILY
>> #define EAI_ADDRFAMILY 0
>> #endif
>>
>> if ((EAI_ADDRFAMILY && gaierr == EAIADDRFAMILY) ||
>>     gaierr == EAI_FAMILY...
>>
>> to shut up gcc 6, while still hoisting the preprocessor logic outside of
>> the expression?
>
> To be honest, I think the preprocessor check inside the expression isn't
> a big deal and clearer than playing games like this.

I wasn't a fan of putting the preprocessor check inside the expression
either, but no clear and concise alternative came to mind.  I think
it's easier to see both intent and effect with the preoprocessor check
than with the above.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-02-26 14:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 15:31 [Qemu-devel] [PATCH] io: fix build on FreeBSD Ed Maste
2016-02-25 15:46 ` Daniel P. Berrange
2016-02-25 16:29 ` Eric Blake
2016-02-25 16:32   ` Daniel P. Berrange
2016-02-25 16:37     ` Eric Blake
2016-02-25 16:41       ` Daniel P. Berrange
2016-02-26 14:25         ` Ed Maste

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).