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

Re: [libvirt] [PATCH 6/8] secret: Have virSecretObjNew consume newdef



On 06/03/2017 03:27 PM, John Ferlan wrote:
> Move the consumption of @newdef into virSecretObjNew and then handle that
> in the calling path.  Because on error the calling code expects to free
> @newdef, unset obj->def for the creation failure error paths.
> 
> Signed-off-by: John Ferlan <jferlan redhat com>
> ---
>  src/conf/virsecretobj.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c
> index c0bcfab..ca13cf8 100644
> --- a/src/conf/virsecretobj.c
> +++ b/src/conf/virsecretobj.c
> @@ -87,7 +87,7 @@ virSecretObjOnceInit(void)
>  VIR_ONCE_GLOBAL_INIT(virSecretObj)
>  
>  static virSecretObjPtr
> -virSecretObjNew(void)
> +virSecretObjNew(virSecretDefPtr def)
>  {
>      virSecretObjPtr obj;
>  
> @@ -98,6 +98,7 @@ virSecretObjNew(void)
>          return NULL;
>  
>      virObjectLock(obj);
> +    obj->def = def;
>  
>      return obj;
>  }
> @@ -384,20 +385,23 @@ virSecretObjListAdd(virSecretObjListPtr secrets,
>          goto error;
>      }
>  
> -    if (!(obj = virSecretObjNew()))
> +    if (!(obj = virSecretObjNew(newdef)))
>          goto cleanup;
>  
>      /* Generate the possible configFile and base64File strings
>       * using the configDir, uuidstr, and appropriate suffix
>       */
>      if (!(obj->configFile = virFileBuildPath(configDir, uuidstr, ".xml")) ||
> -        !(obj->base64File = virFileBuildPath(configDir, uuidstr, ".base64")))
> +        !(obj->base64File = virFileBuildPath(configDir, uuidstr, ".base64"))) {
> +        obj->def = NULL;
>          goto error;
> +    }

I don't quite see the value of this patch, esp. because you have to
manually unset the ->def in each error path.

Michal


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