[libvirt] [PATCH] bhyve: fix virObjectUnlock() usage
Eric Blake
eblake at redhat.com
Mon May 19 17:12:05 UTC 2014
On 05/19/2014 10:57 AM, Roman Bogorodskiy wrote:
> Eric Blake wrote:
>
>> On 05/17/2014 01:44 PM, Roman Bogorodskiy wrote:
>>> In a number of places in the bhyve driver, virObjectUnlock()
>>> is called with an arg without check if the arg is non-NULL, which
>>> could result in passing NULL value and a warning like:
>>>
>>> virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance
>>
>> Doesn't this instead argue that we should fix virObjectUnlock to
>> gracefully handle a NULL parameter, rather than making every caller uglier?
>
> Calling it with NULL seems to be harmless anyway and the only problem
> is this annoying warning.
>
> So, what you propose is checking explicitly for NULL in
> virObjectUnlock before we do virObjectIsClass(), and if the passed
> argument is NULL indeed, just return, without logging anything about
> that?
Yes, since we have other virObject code that special cases NULL (for
example, virObjectUnref).
>
> BTW, that's going to be a vast change, quick grep shows more than 750
> calls of that function.
It doesn't invalidate any existing caller to make virObjectUnlock()
special-case NULL. And while it DOES make any existing caller that also
checks for NULL be a case of redundant code, we don't have to clean all
callers up in a single patch.
--
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/20140519/5e002cbc/attachment-0001.sig>
More information about the libvir-list
mailing list