mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-23 02:04:16 +03:00
util: virtypedparam: Refactor return value of virTypedParamListStealParams
Return the number of parameters via pointer passed as argument to free up possibility to report errors. Strangely all callers actually use 'int' as type for storing the count of elements, thus this function will use the same. The function is also renamed to virTypedParamListSteal. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
88925728f6
commit
ec3a076c9e
@ -113,7 +113,8 @@ adminServerGetThreadPoolParameters(virNetServer *srv,
|
||||
"%s", VIR_THREADPOOL_JOB_QUEUE_DEPTH) < 0)
|
||||
return -1;
|
||||
|
||||
*nparams = virTypedParamListStealParams(paramlist, params);
|
||||
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -279,7 +280,9 @@ adminClientGetInfo(virNetServerClient *client,
|
||||
"%s", VIR_CLIENT_INFO_SELINUX_CONTEXT) < 0)
|
||||
return -1;
|
||||
|
||||
*nparams = virTypedParamListStealParams(paramlist, params);
|
||||
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -322,7 +325,8 @@ adminServerGetClientLimits(virNetServer *srv,
|
||||
"%s", VIR_SERVER_CLIENTS_UNAUTH_CURRENT) < 0)
|
||||
return -1;
|
||||
|
||||
*nparams = virTypedParamListStealParams(paramlist, params);
|
||||
if (virTypedParamListSteal(paramlist, params, nparams) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3560,7 +3560,7 @@ virTypedParamListFetch;
|
||||
virTypedParamListFree;
|
||||
virTypedParamListFromParams;
|
||||
virTypedParamListNew;
|
||||
virTypedParamListStealParams;
|
||||
virTypedParamListSteal;
|
||||
virTypedParamsCheck;
|
||||
virTypedParamsCopy;
|
||||
virTypedParamsDeserialize;
|
||||
|
@ -522,7 +522,9 @@ qemuDomainBackupJobDataToParams(virDomainJobData *jobData,
|
||||
virTypedParamListAddString(par, jobData->errmsg, VIR_DOMAIN_JOB_ERRMSG) < 0)
|
||||
return -1;
|
||||
|
||||
*nparams = virTypedParamListStealParams(par, params);
|
||||
if (virTypedParamListSteal(par, params, nparams) < 0)
|
||||
return -1;
|
||||
|
||||
*type = virDomainJobStatusToType(jobData->status);
|
||||
return 0;
|
||||
}
|
||||
|
@ -17946,7 +17946,9 @@ qemuDomainGetStats(virConnectPtr conn,
|
||||
dom->def->uuid, dom->def->id)))
|
||||
return -1;
|
||||
|
||||
tmp->nparams = virTypedParamListStealParams(params, &tmp->params);
|
||||
if (virTypedParamListSteal(params, &tmp->params, &tmp->nparams) < 0)
|
||||
return -1;
|
||||
|
||||
*record = g_steal_pointer(&tmp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -9873,7 +9873,9 @@ testDomainGetStats(virConnectPtr conn,
|
||||
dom->def->uuid, dom->def->id)))
|
||||
return -1;
|
||||
|
||||
tmp->nparams = virTypedParamListStealParams(params, &tmp->params);
|
||||
if (virTypedParamListSteal(params, &tmp->params, &tmp->nparams) < 0)
|
||||
return -1;
|
||||
|
||||
*record = g_steal_pointer(&tmp);
|
||||
return 0;
|
||||
}
|
||||
|
@ -779,19 +779,27 @@ virTypedParamListFetch(virTypedParamList *list,
|
||||
}
|
||||
|
||||
|
||||
size_t
|
||||
virTypedParamListStealParams(virTypedParamList *list,
|
||||
virTypedParameterPtr *params)
|
||||
int
|
||||
virTypedParamListSteal(virTypedParamList *list,
|
||||
virTypedParameterPtr *par,
|
||||
int *npar)
|
||||
{
|
||||
size_t ret = list->npar;
|
||||
size_t nparams;
|
||||
|
||||
*params = g_steal_pointer(&list->par);
|
||||
if (virTypedParamListFetch(list, par, &nparams) < 0)
|
||||
return -1;
|
||||
|
||||
/* most callers expect 'int', so help them out */
|
||||
*npar = nparams;
|
||||
|
||||
list->par = NULL;
|
||||
list->npar = 0;
|
||||
list->par_alloc = 0;
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virTypedParamList *
|
||||
virTypedParamListFromParams(virTypedParameterPtr *params,
|
||||
size_t nparams)
|
||||
|
@ -143,9 +143,10 @@ virTypedParamListFree(virTypedParamList *list);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virTypedParamList, virTypedParamListFree);
|
||||
virTypedParamList *virTypedParamListNew(void);
|
||||
|
||||
size_t
|
||||
virTypedParamListStealParams(virTypedParamList *list,
|
||||
virTypedParameterPtr *params);
|
||||
int
|
||||
virTypedParamListSteal(virTypedParamList *list,
|
||||
virTypedParameterPtr *par,
|
||||
int *npar);
|
||||
|
||||
int
|
||||
virTypedParamListFetch(virTypedParamList *list,
|
||||
|
Loading…
x
Reference in New Issue
Block a user