From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZowaH-0000cI-C1 for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZowaE-0002eK-4x for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58434) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZowaD-0002eE-Pe for qemu-devel@nongnu.org; Wed, 21 Oct 2015 12:49:50 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 75F9D811D9 for ; Wed, 21 Oct 2015 16:49:49 +0000 (UTC) Date: Wed, 21 Oct 2015 17:49:46 +0100 From: "Daniel P. Berrange" Message-ID: <20151021164946.GE21888@redhat.com> References: <1445442218-32183-1-git-send-email-berrange@redhat.com> <1445442218-32183-3-git-send-email-berrange@redhat.com> <5627B523.9090409@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5627B523.9090409@redhat.com> Subject: Re: [Qemu-devel] [PATCH v1 2/5] sockets: remove use of QemuOpts from socket_listen Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Wed, Oct 21, 2015 at 05:54:11PM +0200, Paolo Bonzini wrote: > > > On 21/10/2015 17:43, Daniel P. Berrange wrote: > > + } > > + if (addr->has_ipv6 && addr->ipv6) { > > + g_printerr("One\n"); > > + return PF_INET6; > > + } > > + if (addr->has_ipv4 && addr->ipv4) { > > + g_printerr("Two\n"); > > + return PF_INET; > > + } > > + if (addr->has_ipv6 && !addr->ipv6) { > > + g_printerr("Three\n"); > > + return PF_INET; > > + } > > + if (addr->has_ipv4 && !addr->ipv4) { > > + g_printerr("Four\n"); > > + return PF_INET6; > > + } > > + g_printerr("Five %d %d %d %d\n", > > + addr->has_ipv4, addr->ipv4, > > + addr->has_ipv6, addr->ipv6); > > + return PF_UNSPEC; > > +} > > + > > Apart from the extra debugging output, I think you can merge as > > if ((addr->has_ipv6 && addr->ipv6) || (addr->has_ipv4 && !addr->ipv4)) { > return PF_INET6; > } > if ((addr->has_ipv4 && addr->ipv4) || (addr->has_ipv6 && !addr->ipv6)) { > return PF_INET; > } > return PF_UNSPEC; > > where the order of the first two is important. Yes, and next time I'll remember to remove the debugging output before posting :-) 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 :|