Received: from eggs.gnu.org ([2001:4830:134:3::10]:40534) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Bkf-0005Y1-LA for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:22:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4Bka-0005Hz-G1 for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:22:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20548) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4Bka-0005Hp-7x for qemu-devel@nongnu.org; Tue, 30 Jul 2013 11:22:12 -0400 From: Markus Armbruster References: <1374201401-11244-1-git-send-email-p.pawit@gmail.com> <51E91BAF.4050903@redhat.com> <20130729170523.4e6a62eb@redhat.com> <87d2q0q4w9.fsf@blackfin.pond.sub.org> <87ob9kk0vv.fsf@blackfin.pond.sub.org> Date: Tue, 30 Jul 2013 17:22:03 +0200 In-Reply-To: (Anthony Liguori's message of "Tue, 30 Jul 2013 08:26:06 -0500") Message-ID: <87k3k86pk4.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Juan Quintela , Pawit Pornkitprasan , qemu-devel , Ryousei Takano , Luiz Capitulino Anthony Liguori writes: > On Tue, Jul 30, 2013 at 1:39 AM, Markus Armbruster wrote: >> Anthony Liguori writes: >> >>> This was part of the discussion way back when this all was first >>> introduced. Since everything was open coded and we had to preserve >>> the semantics, that was the only choice we had. >> >> Yes, there is a difference between an optional parameter with a default >> value and one without. >> >> If you got a value QMP clients cannot send, the difference can be >> eliminated: just pass this value to stand for "nothing". This is the >> case for pointers: just pass NULL. Like everybody else does when >> passing "nothing". >> >> When "nothing" is to be interpreted just like a context-independent >> default value, then the difference doesn't matter. The client doesn't >> care, and the function handling the message becomes simpler. >> >> Only when "nothing" can mean different things do you really need both >> have_FOO and FOO parameters. > > Right, and I'm saying that we have cases like this (especially with > bools). Unfortunately, there are places in the protocol that have No argument there. > tristate values for bool parameters and the behavior is distinctly > different for false, true, and not-present. > > So yes, we could special case those bits and use sentinel values for > everything else. Just realize that we need to handle the above case. Yes, we do, and it's understandable that only the most general case got implemented. >> I can't see why we couldn't introduce default values into the schema if >> we wanted, and use them to simplify generated code. >> >> For pointers, we don't even need schema extensions to simplify away the >> silly have_FOOs. > > Except you have to carefully audit all users to make sure of that. For pointers, the audit should be trivial: change generator to omit the have_FOO, compile, fix up the compile errors (drop have_FOO arguments, replace have_FOO tests be FOO tests), done.