[libvirt] [PATCH] lxc: remove redundant check

Eric Blake eblake at redhat.com
Fri Oct 28 03:51:34 UTC 2011


On 10/27/2011 04:54 AM, Daniel P. Berrange wrote:
>>
>>   882     if (mounts)
>>   883         qsort(mounts, nmounts, sizeof(mounts[0]),
>>   884               lxcContainerChildMountSort);
>>   885
>> *Notes: if mounts is NULL, the above 'if' clause can't be executed,
>> but the following
>> codes will be run.*
>>   886     for (i = 0 ; i<  nmounts ; i++) {

If the static analyzer can't see that nmounts > 0 implies non-NULL 
mounts, then add right here:

sa_assert(mounts);

>>   887         VIR_DEBUG("Umount %s", mounts[i]);
>>
>> So we should use a '{}' to surround with 883: qsort...894: VIR_FREE(mounts[i]);
>
> There's no need.  If  nmounts>  0, then we know mounts != NULL.

Agree - the code is correct as-is; and it should take at most an 
sa_assert to shut up false positives in the analyzers.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org




More information about the libvir-list mailing list