[PATCH 4/4] src: Use g_steal_pointer() more

Erik Skultety eskultet at redhat.com
Tue Feb 1 16:18:50 UTC 2022


On Mon, Jan 31, 2022 at 03:53:42PM +0100, Michal Privoznik wrote:
> There are few places where the g_steal_pointer() is open coded.
> Switch them to calling the g_steal_pointer() function instead.
> Generated by the following spatch:
> 
>   @ rule1 @
>   expression a, b;
>   @@
>     <...
>   - b = a;
>     ... when != b
>   - a = NULL;
>   + b = g_steal_pointer(&a);
>     ...>
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
...

> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 7b684e04ba..52851ac507 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -1780,8 +1780,7 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth,
>  
>      priv->version = g_strdup(os->data->Version);
>  
> -    conn->privateData = priv;
> -    priv = NULL;
> +    conn->privateData = g_steal_pointer(&priv);
>      result = VIR_DRV_OPEN_SUCCESS;
>  
>   cleanup:
> @@ -3518,9 +3517,8 @@ hypervConnectListAllDomains(virConnectPtr conn,
>          doms[count++] = domain;
>      }
>  
> -    if (doms)
> -        *domains = doms;
> -    doms = NULL;
> +    if (domains)
> +        *domains = g_steal_pointer(&doms);

^this is not semantically identical, you need to fix it manually before pushing

Reviewed-by: Erik Skultety <eskultet at redhat.com>




More information about the libvir-list mailing list