[libvirt] [PATCH v3 47/48] util: allow identity to be imported/exported as typed parameters

Andrea Bolognani abologna at redhat.com
Tue Jul 30 20:40:44 UTC 2019


On Mon, 2019-07-29 at 18:11 +0100, Daniel P. Berrangé wrote:
> +++ b/src/util/viridentity.c
> +int virIdentitySetParameters(virIdentityPtr ident,
> +                             virTypedParameterPtr params,
> +                             int nparams)

Return type on a separate line.

[...]
> +    virTypedParamsFree(ident->params, ident->nparams);
> +    ident->params = NULL;
> +    ident->nparams = 0;

I'm obviously a bit unclear on some pretty fundamental details of
the virTypedParam API.

More specifically: shouldn't you set

  ident->maxparams = 0;

here as well? I don't see how it could work otherwise.

> +    if (virTypedParamsCopy(&ident->params, params, nparams) < 0)
> +        return -1;
> +    ident->nparams = nparams;

And here too, don't you need to do

  ident->maxparams = ident->nparams;

for subsequent calls to virTypedParamAdd*() to know whether they need
to allocate additional memeory?

[...]
> +int virIdentityGetParameters(virIdentityPtr ident,
> +                             virTypedParameterPtr *params,
> +                             int *nparams)

Return type on a separate line.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list