Re: [PATCH] qemu: silence clang false positive

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

 



On 08/05/2011 11:14 AM, Eric Blake wrote:
Our logic throws off analyzer tools:

ptr var = NULL;
if (flags == 0) flags = live ? _LIVE : _CONFIG;
if (flags&  _LIVE) do stuff
if (flags&  _CONFIG) var = non-null;
if (flags&  _LIVE) do more stuff
else if (flags&  _CONFIG) use var

the tools keep thinking that var can still be NULL in the last
if clause, adding the hint shuts them up.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Add a
static analysis hint.
---

Off-list, I confirmed with Alex that ccc-analyzer and clang are both
built on the same llvm compiler front end, and thus give the same
analysis.  And I reproduced the static analyzer false positive; this
is the proper fix.

  src/qemu/qemu_driver.c |    3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index ce19be7..a8e4b78 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5679,6 +5679,9 @@ static int qemuDomainSetBlkioParameters(virDomainPtr dom,
              }
          }
      } else if (flags&  VIR_DOMAIN_AFFECT_CONFIG) {
+        /* Clang can't see that if we get here, persistentDef was set.  */
+        sa_assert(persistentDef);
+
          for (i = 0; i<  nparams; i++) {
              virTypedParameterPtr param =&params[i];


Was this ever ACKed? (I don't see it). If not, then ACK. :-)

--
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]