mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
util: json: Add modifier for adding non-negative long values to JSON objects
Similarly to the 'k' modifier for integers introduce 'K' for long integers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
b0f473f49e
commit
a939d4d869
@ -121,6 +121,7 @@ virJSONValueGetType(const virJSONValue *value)
|
||||
*
|
||||
* I: signed long integer value
|
||||
* J: signed long integer value, error if negative
|
||||
* K: signed long integer value, omitted if negative
|
||||
* Z: signed long integer value, omitted if zero
|
||||
* Y: signed long integer value, omitted if zero, error if negative
|
||||
*
|
||||
@ -228,6 +229,7 @@ virJSONValueObjectAddVArgs(virJSONValue **objptr,
|
||||
|
||||
case 'Z':
|
||||
case 'Y':
|
||||
case 'K':
|
||||
case 'J':
|
||||
case 'I': {
|
||||
long long val = va_arg(args, long long);
|
||||
@ -242,6 +244,9 @@ virJSONValueObjectAddVArgs(virJSONValue **objptr,
|
||||
if (!val && (type == 'Z' || type == 'Y'))
|
||||
continue;
|
||||
|
||||
if (val < 0 && type == 'K')
|
||||
continue;
|
||||
|
||||
rc = virJSONValueObjectAppendNumberLong(obj, key, val);
|
||||
} break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user