On 1/1/19 12:20 PM, Richard W.M. Jones wrote:
Should we use attribute((nonnull)) at all? There's a very
interesting
history of this in libvirt -- try looking at commit eefb881 plus the
commits referencing eefb881 -- but it does seem to work for me using
recent GCC and Clang.
I only did a few functions because annotating them gets old quickly...
For internal usage, I think the annotations help a working compiler do a
better job. I don't know if modern gcc does better than the old one that
you mention being the reason that libvirt doesn't use it. I also
haven't researched if libvirt could change their policy now (that is,
are we stuck with avoiding something because of having been burned in
the past, even though we would no longer be burned by it?).
For installed headers, where the annotations are used by clients
compiling a plugin, we need to be a bit more careful - while nbdkit
itself requires compilation with gcc or clang (for things like our
automatic variable cleanups) and therefore has unconditional support for
attributes, I think we should still aim for a generic plugin being
compiled with a standards-compliant compiler rather than requiring
clients to use just gcc or clang. It's not impossible to make the use
of attributes in a public header be properly guarded by the
preprocessor, as long as we remember to do it right.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org