Received: from eggs.gnu.org ([2001:4830:134:3::10]:50117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpEhW-0003zH-Bq for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:10:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZpEhS-00015t-Ae for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:10:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZpEhS-00015p-4l for qemu-devel@nongnu.org; Thu, 22 Oct 2015 08:10:30 -0400 From: Markus Armbruster References: <1444648509-29179-1-git-send-email-berrange@redhat.com> <1444648509-29179-4-git-send-email-berrange@redhat.com> <1445449978.7681.367.camel@ifi.uio.no> <20151022094330.GD9079@redhat.com> Date: Thu, 22 Oct 2015 14:10:26 +0200 In-Reply-To: (Peter Maydell's message of "Thu, 22 Oct 2015 11:02:03 +0100") Message-ID: <878u6v6r4d.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v2 03/16] sockets: allow port to be NULL when listening on IP address List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: QEMU Developers , "Dr. David Alan Gilbert" , Paolo Bonzini , Knut Omang Peter Maydell writes: > On 22 October 2015 at 10:43, Daniel P. Berrange wrote: >> For reasons I don't understand, it appears that even string >> fields which are marked as optional get a 'has_XXX' flag, >> to distinguish betweeen a NULL string and an unset string. >> I struggle to imagine why we need this. It makes sense for >> integer/boolean types, but I would have thought just checking >> for NULL was sufficient for string types. > > I think the argument here is pure consistency. *Every* optional > field should be implemented as has_fieldname (bool) plus fieldname > (actual value). Special casing string types because we happen > to have a special value we can use to indicate 'no string' > seems to me like it would cause more confusion than it would > be worth. Having a has_FOO for pointer-valued FOOs also causes confusion, because it begs questions like "does has_FOO imply FOO != NULL?" and "if !has_FOO, do I have to worry about freeing FOO?". I believe we have these has_FOOs not because someone tried to minimize confusion, but due to laziness: it was simpler to blindly generate the has_FOO for every FOO. Since I don't think distinguishing "pointer argument omitted" from "pointer argument is null" makes sense, I want the has_FOO killed for pointer FOOs. Perhaps it's even in the QAPI review queue already, which Eric keeps filling faster than I can drain it :)