On Thu, Dec 22, 2022 at 14:01:38 +0100, Michal Privoznik wrote: > The @hash variable inside of virQEMUCapsProbeQMPHostCPU() is used > only within a loop, but declared at the beginning of the > function. Bring the variable declaration into the said loop. The variable is used by two loops inside a block. You are moving it inside the block, but not the loop as it needs to outlive it. > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > src/qemu/qemu_capabilities.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c > index 3aba9299b1..adcd3b21a6 100644 > --- a/src/qemu/qemu_capabilities.c > +++ b/src/qemu/qemu_capabilities.c > @@ -3035,7 +3035,6 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, > const char *model = virQEMUCapsTypeIsAccelerated(virtType) ? "host" : "max"; > g_autoptr(qemuMonitorCPUModelInfo) modelInfo = NULL; > g_autoptr(qemuMonitorCPUModelInfo) nonMigratable = NULL; > - g_autoptr(GHashTable) hash = NULL; > g_autoptr(virCPUDef) cpu = NULL; > qemuMonitorCPUModelExpansionType type; > bool fail_no_props = true; > @@ -3079,6 +3078,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCaps *qemuCaps, > return -1; > > if (nonMigratable) { > + g_autoptr(GHashTable) hash = NULL; You can also directly do: g_autoptr(GHashTable) hash = virHashNew(NULL); and remove the assignment which is just below this context. > qemuMonitorCPUProperty *prop; > qemuMonitorCPUProperty *nmProp; Reviewed-by: Peter Krempa <pkrempa@xxxxxxxxxx>