[libvirt] [PATCH] qemu: silence clang false positive
Laine Stump
laine at laine.org
Thu Aug 11 14:51:15 UTC 2011
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 =¶ms[i];
>
Was this ever ACKed? (I don't see it). If not, then ACK. :-)
More information about the libvir-list
mailing list