[Libguestfs] [PATCH nbdkit] include: Annotate function parameters with attribute((nonnull)).

Richard W.M. Jones rjones at redhat.com
Wed Jan 2 14:49:32 UTC 2019


On Wed, Jan 02, 2019 at 08:48:08AM -0600, Eric Blake wrote:
> 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.

OK good points, let me come back with a v2 of this patch.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list