Re: [PATCH] lxc: remove redundant check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]