Re: [PATCH] util: Use virStorageSourceNew in virStorageFileMetadataNew

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2/18/19 7:27 AM, Peter Krempa wrote:
> Commit dcda2bf4c110 forgot to fix this one instance.
> 
> Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> ---
>  src/util/virstoragefile.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 

Right fix as far as I'm concerned; however, I am curious to know whether
this passes the MinGW build test because this is exactly where things
started to break down for VIR_AUTOPTR usage.

VIR_AUTOUNREF could also be used more liberally in this module...

> diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
> index 5927140a66..b2e308d81d 100644
> --- a/src/util/virstoragefile.c
> +++ b/src/util/virstoragefile.c
> @@ -1119,22 +1119,20 @@ static virStorageSourcePtr
>  virStorageFileMetadataNew(const char *path,
>                            int format)
>  {
> -    virStorageSourcePtr def = NULL;
> +    VIR_AUTOUNREF(virStorageSourcePtr) def = NULL;
> +    virStorageSourcePtr ret = NULL;

Erik prefers the usage of VIR_AUTO* defs last (IOW, swap these).

As long as this gets through the MinGW build test, then

Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx>

John

Altering other virStorageSource refs here to use VIR_AUTOUNREF would be
the next step (and of course getting them through MinGW build test).

> 
> -    if (VIR_ALLOC(def) < 0)
> +    if (!(def = virStorageSourceNew()))
>          return NULL;
> 
>      def->format = format;
>      def->type = VIR_STORAGE_TYPE_FILE;
> 
>      if (VIR_STRDUP(def->path, path) < 0)
> -        goto error;
> -
> -    return def;
> +        return NULL;
> 
> - error:
> -    virObjectUnref(def);
> -    return NULL;
> +    VIR_STEAL_PTR(ret, def);
> +    return ret;
>  }
> 
> 


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux