Alberto Garcia <[email protected]> writes: > On Fri 08 Sep 2017 12:02:14 PM CEST, Markus Armbruster wrote: > >>> + fse = get_fsdev_fsentry(arg->has_id ? arg->id : NULL); >> >> !arg->has_id implies !arg->id. > > Hey Markus, > > I have the impression that I've also written code that never uses > arg->foo when arg->has_foo is false. > > Can we then assume that to be NULL/0 in all cases? Also for other data > types (int, bool, ...)?
QAPI code always passes zero FOOs along with false has_FOOs. Anything that doesn't is a bug. This is particular important when FOO is a pointer; we don't want to pass around pointers pointing to random junk in the hope that everybody will obediently check their has_FOO before dereferencing. Other code might not always be as well-behaved. In random context, checking has_FOO is probably safer. I still want to eliminate has_FOO for pointer-valued FOO. So much to do, so little time!
