mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
util: virtypedparam: Simplify error handling in virTypedParamListAdd*
Don't check the return value of 'virTypedParamListExtend' which will always be a valid pointer and 'virTypedParameterAssignValue' always returns 0. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
ff8a626c58
commit
6813a46db5
@ -245,7 +245,7 @@ virTypedParameterAssignValueVArgs(virTypedParameterPtr param,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static void
|
||||
virTypedParameterAssignValue(virTypedParameterPtr param,
|
||||
virTypedParameterType type,
|
||||
...)
|
||||
@ -255,8 +255,6 @@ virTypedParameterAssignValue(virTypedParameterPtr param,
|
||||
va_start(ap, type);
|
||||
virTypedParameterAssignValueVArgs(param, type, ap, true);
|
||||
va_end(ap);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -776,13 +774,11 @@ virTypedParamListAddInt(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_INT, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -798,13 +794,11 @@ virTypedParamListAddUInt(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -820,13 +814,11 @@ virTypedParamListAddLLong(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_LLONG, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -842,13 +834,11 @@ virTypedParamListAddULLong(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -864,13 +854,11 @@ virTypedParamListAddString(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_STRING, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -886,13 +874,11 @@ virTypedParamListAddBoolean(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_BOOLEAN, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
@ -908,13 +894,11 @@ virTypedParamListAddDouble(virTypedParamList *list,
|
||||
const char *namefmt,
|
||||
...)
|
||||
{
|
||||
virTypedParameterPtr par;
|
||||
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
if (!(par = virTypedParamListExtend(list)) ||
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value) < 0)
|
||||
return -1;
|
||||
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_DOUBLE, value);
|
||||
|
||||
va_start(ap, namefmt);
|
||||
ret = virTypedParamSetNameVPrintf(par, namefmt, ap);
|
||||
|
Loading…
Reference in New Issue
Block a user