[PATCH 001/103] virJSONValueObjectAddVArgs: Add 'k' convertor for formatting non-negative integers
Kristina Hanicova
khanicov at redhat.com
Fri Oct 8 07:14:31 UTC 2021
On Thu, Oct 7, 2021 at 6:43 PM Ján Tomko <jtomko at redhat.com> wrote:
> On a Thursday in 2021, Peter Krempa wrote:
> >In many cases we use a signed value, but use the sign to note that it
> >was not assigned. For converting to JSON objects it will be handy to
> >have possibility to do this automatically.
> >
> >Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> >---
> > src/util/virjson.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> >diff --git a/src/util/virjson.c b/src/util/virjson.c
> >index 9adcea4fff..70ea71b505 100644
> >--- a/src/util/virjson.c
> >+++ b/src/util/virjson.c
> >@@ -115,6 +115,7 @@ virJSONValueGetType(const virJSONValue *value)
> > *
> > * i: signed integer value
> > * j: signed integer value, error if negative
> >+ * k: signed integer value, omitted if negative
> > * z: signed integer value, omitted if zero
> > * y: signed integer value, omitted if zero, error if negative
> > *
> >@@ -189,6 +190,7 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
> >
> > case 'z':
> > case 'y':
> >+ case 'k':
> > case 'j':
> > case 'i': {
> > int val = va_arg(args, int);
> >@@ -200,7 +202,10 @@ virJSONValueObjectAddVArgs(virJSONValue *obj,
> > return -1;
> > }
> >
> >- if (!val && (type == 'z' || type == 'y'))
> >+ if (val == 0 && (type == 'z' || type == 'y'))
> >+ continue;
> >+
>
> Please split out this cosmetic style change.
>
Please don't.
>+ if (val < 0 && type == 'k')
> > continue;
> >
>
> k.
>
> I mean
> Reviewed-by: Ján Tomko <jtomko at redhat.com>
>
> Jano
>
Kristina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20211008/05d97711/attachment-0001.htm>
More information about the libvir-list
mailing list