[libvirt] [PATCH] virsh-nodedev: Avoid spurious errors

Eric Blake eblake at redhat.com
Mon Jun 2 15:12:39 UTC 2014


On 06/02/2014 08:52 AM, Michal Privoznik wrote:
> Our public free functions explicitly don't accept NULL pointers
> (sigh). Therefore, callers must do something like this:
> 
>     if (dev)
>         virNodeDeviceFree(dev);

Back-compat stinks - changing an error into silent success may break
older code that was relying on the error, so I'm not brave enough to
change the public API.

I wonder if it would be appropriate to annotate our public API with
non-NULL markers, so that at least the compiler could warn on calls to
the API with a NULL pointer.

> 
> And we are not doing that on two places I've found. This leads to
> dummy error message thrown by virsh:
> 
>     virsh # nodedev-dumpxml nonexistent-device
>     error: Could not find matching device 'nonexistent-device'
>     error: invalid node device pointer in virNodeDeviceFree
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  tools/virsh-nodedev.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

At any rate, whether or not we choose to make further changes to
libvirt.h, your patch is stand-alone correct. ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140602/93d0045f/attachment-0001.sig>


More information about the libvir-list mailing list