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(a)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(a)redhat.com>
Jano