Re: [PATCH 1/4] vz: make output arguments in prlsdkGetDomainIds as optional

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

 




On 28.01.2016 18:38, Mikhail Feoktistov wrote:
> prlsdkGetDomainIds() returns name and uuid for specified instance.
> Now output arguments can be NULL.
> It allows to get only necessary info(name or uuid).
> ---
>  src/vz/vz_sdk.c | 34 +++++++++++++++++++---------------
>  1 file changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
> index 7973d6a..8181149 100644
> --- a/src/vz/vz_sdk.c
> +++ b/src/vz/vz_sdk.c
> @@ -346,25 +346,29 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
>      PRL_UINT32 len;
>      PRL_RESULT pret;
>  
> -    len = 0;
> -    /* get name length */
> -    pret = PrlVmCfg_GetName(sdkdom, NULL, &len);
> -    prlsdkCheckRetGoto(pret, error);
> +    if (name) {
> +        len = 0;
> +        /* get name length */
> +        pret = PrlVmCfg_GetName(sdkdom, NULL, &len);
> +        prlsdkCheckRetGoto(pret, error);
>  
> -    if (VIR_ALLOC_N(*name, len) < 0)
> -        goto error;
> +        if (VIR_ALLOC_N(*name, len) < 0)
> +            goto error;
>  
> -    PrlVmCfg_GetName(sdkdom, *name, &len);
> -    prlsdkCheckRetGoto(pret, error);
> +        PrlVmCfg_GetName(sdkdom, *name, &len);
> +        prlsdkCheckRetGoto(pret, error);
> +    }
>  
> -    len = sizeof(uuidstr);
> -    PrlVmCfg_GetUuid(sdkdom, uuidstr, &len);
> -    prlsdkCheckRetGoto(pret, error);
> +    if (uuid) {
> +        len = sizeof(uuidstr);
> +        PrlVmCfg_GetUuid(sdkdom, uuidstr, &len);
> +        prlsdkCheckRetGoto(pret, error);
>  
> -    if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
> -        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> -                       _("Domain UUID is malformed or empty"));
> -        goto error;
> +        if (prlsdkUUIDParse(uuidstr, uuid) < 0) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                           _("Domain UUID is malformed or empty"));
> +            goto error;
> +        }
>      }
>  
>      return 0;
>
ACK, but I would add *name = NULL as another patch or we depend on 
caller setting it for us if we follow error path.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]