mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-29 20:11:16 +00:00
util: typedparam: Introduce virTypedParamListAddUnsigned
The new helper adds a unsigned value, stored as _UINT if it fits into the type and stored as _ULLONG otherwise. This is useful for the statistics code which is quite tolerant to changes in type in cases when we'll need more range for the value. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f9f40a6d4b
commit
e280e83bff
@ -3555,6 +3555,7 @@ virTypedParamListAddLLong;
|
|||||||
virTypedParamListAddString;
|
virTypedParamListAddString;
|
||||||
virTypedParamListAddUInt;
|
virTypedParamListAddUInt;
|
||||||
virTypedParamListAddULLong;
|
virTypedParamListAddULLong;
|
||||||
|
virTypedParamListAddUnsigned;
|
||||||
virTypedParamListConcat;
|
virTypedParamListConcat;
|
||||||
virTypedParamListFetch;
|
virTypedParamListFetch;
|
||||||
virTypedParamListFree;
|
virTypedParamListFree;
|
||||||
|
@ -920,6 +920,42 @@ virTypedParamListAddULLong(virTypedParamList *list,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virTypedParamListAddUnsigned:
|
||||||
|
* @list: typed parameter list
|
||||||
|
* @value: value to add (see below on details)
|
||||||
|
* @namefmt: formatting string for constructing the name of the added value
|
||||||
|
* @...: additional parameters to format the name
|
||||||
|
*
|
||||||
|
* Adds a new typed parameter to @list. The name of the parameter is formatted
|
||||||
|
* from @fmt.
|
||||||
|
*
|
||||||
|
* @value is added as VIR_TYPED_PARAM_UINT, unless it doesn't fit into the data
|
||||||
|
* type in which case it's added as VIR_TYPED_PARAM_ULLONG.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virTypedParamListAddUnsigned(virTypedParamList *list,
|
||||||
|
unsigned long long value,
|
||||||
|
const char *namefmt,
|
||||||
|
...)
|
||||||
|
{
|
||||||
|
virTypedParameterPtr par = virTypedParamListExtend(list);
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (value > UINT_MAX) {
|
||||||
|
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_ULLONG, value);
|
||||||
|
} else {
|
||||||
|
unsigned int ival = value;
|
||||||
|
|
||||||
|
virTypedParameterAssignValue(par, VIR_TYPED_PARAM_UINT, ival);
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(ap, namefmt);
|
||||||
|
virTypedParamSetNameVPrintf(list, par, namefmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
virTypedParamListAddString(virTypedParamList *list,
|
virTypedParamListAddString(virTypedParamList *list,
|
||||||
const char *value,
|
const char *value,
|
||||||
|
@ -187,6 +187,12 @@ virTypedParamListAddULLong(virTypedParamList *list,
|
|||||||
...)
|
...)
|
||||||
G_GNUC_PRINTF(3, 4);
|
G_GNUC_PRINTF(3, 4);
|
||||||
void
|
void
|
||||||
|
virTypedParamListAddUnsigned(virTypedParamList *list,
|
||||||
|
unsigned long long value,
|
||||||
|
const char *namefmt,
|
||||||
|
...)
|
||||||
|
G_GNUC_PRINTF(3, 4);
|
||||||
|
void
|
||||||
virTypedParamListAddString(virTypedParamList *list,
|
virTypedParamListAddString(virTypedParamList *list,
|
||||||
const char *value,
|
const char *value,
|
||||||
const char *namefmt,
|
const char *namefmt,
|
||||||
|
Loading…
Reference in New Issue
Block a user