From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
Anthony Liguori <aliguori@amazon.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] qapi-commands.py generates code that uses uninitialized variables
Date: Fri, 11 Apr 2014 07:11:49 -0600 [thread overview]
Message-ID: <5347EA15.3040903@redhat.com> (raw)
In-Reply-To: <CAFEAcA_SzS-Hj98x-OkrijJrTxLyO57jnHWwWt_NW=MS6wVQUA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]
On 04/11/2014 01:27 AM, Peter Maydell wrote:
> On 11 April 2014 02:40, Eric Blake <eblake@redhat.com> 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.
The called code ALSO needs a fix, but guaranteeing that
'have_foo==false' implies 'foo==0' is MUCH nicer than 'have_foo==false'
implies 'foo is indeterminate'. For this particular caller, an
indeterminate foo had detrimental effects, and a known foo==0 happened
to be the right default. I agree that we can't always predict the right
default for all callers, but avoiding random behavior can be considered
a bug fix in its own right, and if we make it part of the contract that
callers can rely on zero initialization, we could simplify a lot of
callers that ARE happy with a 0 default.
--
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 --]
next prev parent reply other threads:[~2014-04-11 13:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-17 23:58 [Qemu-devel] qapi-commands.py generates code that uses uninitialized variables Peter Maydell
2014-03-18 9:32 ` Markus Armbruster
2014-03-20 19:21 ` Michael Roth
2014-03-26 14:34 ` Markus Armbruster
2014-03-28 14:19 ` Peter Maydell
2014-04-11 1:40 ` Eric Blake
2014-04-11 7:27 ` Peter Maydell
2014-04-11 7:48 ` Fam Zheng
2014-04-11 13:11 ` Eric Blake [this message]
2014-04-11 13:27 ` Peter Maydell
2014-04-11 14:01 ` Laszlo Ersek
2014-05-20 11:46 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5347EA15.3040903@redhat.com \
--to=eblake@redhat.com \
--cc=aliguori@amazon.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).