From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c9OzC-0001Og-NI for qemu-devel@nongnu.org; Tue, 22 Nov 2016 23:16:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c9Oz9-0001zg-Gy for qemu-devel@nongnu.org; Tue, 22 Nov 2016 23:16:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c9Oz9-0001zL-Be for qemu-devel@nongnu.org; Tue, 22 Nov 2016 23:16:39 -0500 From: Eric Blake Date: Tue, 22 Nov 2016 22:16:26 -0600 Message-Id: <1479874588-1969-2-git-send-email-eblake@redhat.com> In-Reply-To: <1479874588-1969-1-git-send-email-eblake@redhat.com> References: <1479874588-1969-1-git-send-email-eblake@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] qmp-event: Avoid qobject_from_jsonf("%"PRId64) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: programmingkidx@gmail.com, armbru@redhat.com, pbonzini@redhat.com, Michael Roth 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, it is just as easy to open-code the few callers that were relying on this particular conversion. Reported by: G 3 Signed-off-by: Eric Blake --- qapi/qmp-event.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qapi/qmp-event.c b/qapi/qmp-event.c index 8bba165..26e10a1 100644 --- a/qapi/qmp-event.c +++ b/qapi/qmp-event.c @@ -16,6 +16,8 @@ #include "qemu-common.h" #include "qapi/qmp-event.h" #include "qapi/qmp/qstring.h" +#include "qapi/qmp/qdict.h" +#include "qapi/qmp/qint.h" #include "qapi/qmp/qjson.h" static QMPEventFuncEmit qmp_emit; @@ -33,7 +35,7 @@ QMPEventFuncEmit qmp_event_get_func_emit(void) static void timestamp_put(QDict *qdict) { int err; - QObject *obj; + QDict *stamp; qemu_timeval tv; int64_t sec, usec; @@ -47,10 +49,10 @@ static void timestamp_put(QDict *qdict) usec = tv.tv_usec; } - obj = qobject_from_jsonf("{ 'seconds': %" PRId64 ", " - "'microseconds': %" PRId64 " }", - sec, usec); - qdict_put_obj(qdict, "timestamp", obj); + stamp = qdict_new(); + qdict_put(stamp, "seconds", qint_from_int(sec)); + qdict_put(stamp, "microseconds", qint_from_int(usec)); + qdict_put(qdict, "timestamp", stamp); } /* -- 2.7.4