[libvirt PATCH 04/10] qemuMonitorGetAllBlockStatsInfo: Use automatic memory management

Daniel P. Berrangé berrange at redhat.com
Mon Jul 5 15:47:59 UTC 2021


On Mon, Jul 05, 2021 at 05:36:43PM +0200, Tim Wiederhake wrote:
> Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
> ---
>  src/qemu/qemu_monitor.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index 86aabc98c3..f08b43bbfb 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -2155,7 +2155,7 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitor *mon,
>                                  bool backingChain)
>  {
>      int ret;
> -    GHashTable *stats = virHashNew(g_free);
> +    g_autoptr(GHashTable) stats = virHashNew(g_free);
>  
>      VIR_DEBUG("ret_stats=%p, backing=%d", ret_stats, backingChain);
>  
> @@ -2165,14 +2165,10 @@ qemuMonitorGetAllBlockStatsInfo(qemuMonitor *mon,
>      ret = qemuMonitorJSONGetAllBlockStatsInfo(mon, stats, backingChain);
>  
>      if (ret < 0)
> -        goto error;
> +        return -1;
>  
> -    *ret_stats = stats;
> +    *ret_stats = g_steal_pointer(&stats);
>      return ret;
> -
> - error:
> -    virHashFree(stats);
> -    return -1;
>  }

This fixes the bug introduced by the previous patch. The changes need
to be reversed to ensure bisect works correctly.

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|




More information about the libvir-list mailing list