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