Similarly to the 'k' modifier for integers introduce 'K' for long
integers.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/virjson.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 6e13e97e15..ae970c7653 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -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;
--
2.35.3