mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
virTypedParamsFilter: Adjust return type and docs
The 'virTypedParamsFilter' function can't fail and thus it never returns negative values. Change the return type to 'size_t' and adjust callers to not check the return value for being negative. Adjust the docs to hilight this and also the fact that the filtered typed param list returned via @ret is not a deep copy and thus callers must not use the common function to free it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
165b30e06a
commit
933ab93e8f
@ -394,18 +394,22 @@ virTypedParamsCopy(virTypedParameterPtr *dst,
|
||||
* @ret: pointer to the returned array
|
||||
*
|
||||
* Filters @params retaining only the parameters named @name in the
|
||||
* resulting array @ret. Caller should free the @ret array but not
|
||||
* the items since they are pointing to the @params elements.
|
||||
* resulting array @ret.
|
||||
*
|
||||
* Returns amount of elements in @ret on success, -1 on error.
|
||||
* Important Caller should free the @ret array but not the items since they are
|
||||
* pointing to the @params elements. I.e. callers must not use
|
||||
* 'virTypedParamsFree' or equivalent on pointer returned via @ret.
|
||||
*
|
||||
* Returns amount of elements in @ret.
|
||||
*/
|
||||
int
|
||||
size_t
|
||||
virTypedParamsFilter(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
const char *name,
|
||||
virTypedParameterPtr **ret)
|
||||
{
|
||||
size_t i, n = 0;
|
||||
size_t i;
|
||||
size_t n = 0;
|
||||
|
||||
*ret = g_new0(virTypedParameterPtr, nparams);
|
||||
|
||||
@ -443,7 +447,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params,
|
||||
const char ***values)
|
||||
{
|
||||
size_t i, n;
|
||||
int nfiltered;
|
||||
size_t nfiltered;
|
||||
virTypedParameterPtr *filtered = NULL;
|
||||
|
||||
virCheckNonNullArgGoto(values, error);
|
||||
@ -451,9 +455,6 @@ virTypedParamsGetStringList(virTypedParameterPtr params,
|
||||
|
||||
nfiltered = virTypedParamsFilter(params, nparams, name, &filtered);
|
||||
|
||||
if (nfiltered < 0)
|
||||
goto error;
|
||||
|
||||
if (nfiltered)
|
||||
*values = g_new0(const char *, nfiltered);
|
||||
|
||||
|
@ -81,7 +81,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
const char *name,
|
||||
const char ***values);
|
||||
int
|
||||
size_t
|
||||
virTypedParamsFilter(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
const char *name,
|
||||
|
Loading…
x
Reference in New Issue
Block a user