[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64) |
Date: |
Wed, 23 Nov 2016 04:25:31 -0500 (EST) |
> The qobject_from_jsonf() function implements a pseudo-printf
> language for creating a QObject; however, it is hard-coded to
> only parse a subset of formats understood by printf(). In
> particular, any use of a 64-bit integer works only if the
> system's definition of PRId64 matches what the parser expects;
> which works on glibc (%lld) and mingw (%I64d), but not on
> Mac OS (%qd). Rather than enhance the parser, we have already
> converted almost all clients to use an alternative method;
> convert or eliminate the remaining uses in the testsuite, and
> rip out this code from the parser.
>
> Ripping it all out means that we will now uniformly get
> failures on all platforms that try to use dynamic JSON with
> 64-bit numbers. Ultimately, I plan for later patches to rip
> out dynamic JSON altogether, but that is more invasive and
> therefore not appropriate for the 2.8 release, while this
> patch fixes an actual testsuite failure of check-qjson on
> Mac OS.
>
> Reported by: G 3 <address@hidden>
> Signed-off-by: Eric Blake <address@hidden>
This is throwing out the baby with the bathwater. %lld works
just fine for long long. Throwing away %I64d is fine though...
> @@ -964,7 +964,6 @@ static void vararg_number(void)
> QInt *qint;
> QFloat *qfloat;
> int value = 0x2342;
> - int64_t value64 = 0x2342342343LL;
> double valuef = 2.323423423;
>
> obj = qobject_from_jsonf("%d", value);
> @@ -976,15 +975,6 @@ static void vararg_number(void)
>
> QDECREF(qint);
>
> - obj = qobject_from_jsonf("%" PRId64, value64);
> - g_assert(obj != NULL);
> - g_assert(qobject_type(obj) == QTYPE_QINT);
> -
> - qint = qobject_to_qint(obj);
> - g_assert(qint_get_int(qint) == value64);
> -
> - QDECREF(qint);
> -
> obj = qobject_from_jsonf("%f", valuef);
> g_assert(obj != NULL);
> g_assert(qobject_type(obj) == QTYPE_QFLOAT);
if you change the test to use %lld and long long instead of int64_t.
> diff --git a/tests/test-qobject-input-visitor.c
> b/tests/test-qobject-input-visitor.c
> index 26c5012..945404a 100644
> --- a/tests/test-qobject-input-visitor.c
> +++ b/tests/test-qobject-input-visitor.c
> @@ -83,10 +83,11 @@ static Visitor
> *visitor_input_test_init_raw(TestInputVisitorData *data,
> static void test_visitor_in_int(TestInputVisitorData *data,
> const void *unused)
> {
> - int64_t res = 0, value = -42;
> + int64_t res = 0;
> + int value = -42;
> Visitor *v;
>
> - v = visitor_input_test_init(data, "%" PRId64, value);
> + v = visitor_input_test_init(data, "%d", value);
>
> visit_type_int(v, NULL, &res, &error_abort);
> g_assert_cmpint(res, ==, value);
> --
> 2.7.4
>
>
This part is fine I guess.
Paolo
- Re: [Qemu-devel] [PATCH 2/3] test-qga: Avoid qobject_from_jsonf("%"PRId64), (continued)
[Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/22
[Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/22
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64),
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Markus Armbruster, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Markus Armbruster, 2016/11/23
- Re: [Qemu-devel] [PATCH 3/3] qapi: Drop support for qobject_from_jsonf("%"PRId64), Eric Blake, 2016/11/23