From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYWCy-0004ik-Ln for qemu-devel@nongnu.org; Fri, 11 Apr 2014 03:49:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WYWCs-0003qS-0E for qemu-devel@nongnu.org; Fri, 11 Apr 2014 03:49:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40677) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WYWCr-0003q8-P7 for qemu-devel@nongnu.org; Fri, 11 Apr 2014 03:49:01 -0400 Date: Fri, 11 Apr 2014 15:48:02 +0800 From: Fam Zheng Message-ID: <20140411074801.GA31773@T430.nay.redhat.com> References: <87bnx3vomf.fsf@blackfin.pond.sub.org> <20140320192134.8983.86526@loki> <53474826.9060903@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] qapi-commands.py generates code that uses uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Markus Armbruster , QEMU Developers , Anthony Liguori , Michael Roth On Fri, 04/11 08:27, Peter Maydell wrote: > On 11 April 2014 02:40, Eric Blake wrote: > > We uncovered a real bug that would be fixed by this patch: > > https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg01745.html > > No, that's a bug in the called code. The API here defines > that for optional parameters, if the have_foo bool is false > then the foo argument isn't set. The generated code > can't know the correct default value (it just happens > to be 0 in the case you point out, but what if the default > speed were 100?) so this must be handled by the called > code. > Default value for a variable isn't default value for API logic, so apparently called code must always handle both have_foo and foo. But there is a point to take this patch from the language perspective, to avoid that an unset variable is passed as a parameter from generated code. Thanks, Fam