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

Re: [libvirt] [PATCH] lxc: remove redundant check



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


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