qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [RFC v4 19/21] blockjobs: Expose manual pr


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [RFC v4 19/21] blockjobs: Expose manual property
Date: Wed, 28 Feb 2018 13:27:00 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 02/28/2018 01:20 PM, John Snow wrote:

+    if (!backup->has_manual) {
+        backup->manual = false;
+    }

I think this is unnecessary these days, NULL/0/false is the default
value for QMP/QAPI.


That's what I get for cargo cult. Eric, confirm/deny? Should I remove
the other auto-false defaults too?

Either we have them all or none of them for consistency.

Someday it would be nice to have QAPI provide decent non-0 defaults as desired. But for now, Kevin is correct - the QAPI generator guarantees that you will have NULL/0/false values for 'has' anywhere that 'has_foo' is false. We're less consistent on whether we ensure that we don't access 'foo' without checking 'has_foo' first, but if you want to simplify by relying on the default initialization to 0, you will not be the first person to do so.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]