[PATCH] conf: snapshot/checkpoint: Rewrite 'AlignDisk' logic to appease clang

Ján Tomko jtomko at redhat.com
Mon Aug 23 12:32:42 UTC 2021


On a Monday in 2021, Peter Krempa wrote:
>New clang has a false-positive about value of 'olddisks' being unused
>after being set. This is clearly wrong because we want to use
>'g_autofree' to clear it later.
>
>While I'm against modifying good code for the sake of bad static
>analysis in this case it's not obvious that we depend on the lifetime of
>'olddisks' being needed until the end of the function as we store
>pointers into it into the hash table and later copy them out.
>
>Rewrite the code by assigning to 'olddisks' earlier and then using
>'olddisks' in the loop, so it's clear where the lifetime of the objects
>ends, and this should also silence the warning.
>
>Signed-off-by: Peter Krempa <pkrempa at redhat.com>
>---
> src/conf/checkpoint_conf.c | 14 ++++++++------
> src/conf/snapshot_conf.c   | 14 ++++++++------
> 2 files changed, 16 insertions(+), 12 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko at redhat.com>

Jano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20210823/a1369fcb/attachment-0001.sig>


More information about the libvir-list mailing list