From nobody Wed Nov 5 10:30:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535044521930355.7590977350451; Thu, 23 Aug 2018 10:15:21 -0700 (PDT) Received: from localhost ([::1]:37879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fstCa-0004Ru-LX for importer@patchew.org; Thu, 23 Aug 2018 13:15:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fsskN-0000SL-43 for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:46:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fsskL-0006L0-Bs for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:46:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59564 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fsskK-0006KJ-VU for qemu-devel@nongnu.org; Thu, 23 Aug 2018 12:46:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A14B804B9F4; Thu, 23 Aug 2018 16:46:08 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6ECE22026DE4; Thu, 23 Aug 2018 16:46:08 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8A1D8110E366; Thu, 23 Aug 2018 18:40:26 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 23 Aug 2018 18:40:18 +0200 Message-Id: <20180823164025.12553-52-armbru@redhat.com> In-Reply-To: <20180823164025.12553-1-armbru@redhat.com> References: <20180823164025.12553-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 23 Aug 2018 16:46:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 23 Aug 2018 16:46:08 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'armbru@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3 51/58] json: Make JSONToken opaque outside json-parser.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- include/qapi/qmp/json-parser.h | 4 ++++ include/qapi/qmp/json-streamer.h | 7 ------- qobject/json-parser.c | 19 +++++++++++++++++++ qobject/json-streamer.c | 8 +------- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/include/qapi/qmp/json-parser.h b/include/qapi/qmp/json-parser.h index a34209db7a..21b23d7bec 100644 --- a/include/qapi/qmp/json-parser.h +++ b/include/qapi/qmp/json-parser.h @@ -15,7 +15,11 @@ #define QEMU_JSON_PARSER_H =20 #include "qemu-common.h" +#include "qapi/qmp/json-lexer.h" =20 +typedef struct JSONToken JSONToken; + +JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr); QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp); =20 #endif diff --git a/include/qapi/qmp/json-streamer.h b/include/qapi/qmp/json-strea= mer.h index d1d7fe2595..29950ac37c 100644 --- a/include/qapi/qmp/json-streamer.h +++ b/include/qapi/qmp/json-streamer.h @@ -16,13 +16,6 @@ =20 #include "qapi/qmp/json-lexer.h" =20 -typedef struct JSONToken { - int type; - int x; - int y; - char str[]; -} JSONToken; - typedef struct JSONMessageParser { void (*emit)(void *opaque, QObject *json, Error *err); diff --git a/qobject/json-parser.c b/qobject/json-parser.c index e9a9f937f3..a247875f14 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -26,6 +26,13 @@ #include "qapi/qmp/json-lexer.h" #include "qapi/qmp/json-streamer.h" =20 +struct JSONToken { + JSONTokenType type; + int x; + int y; + char str[]; +}; + typedef struct JSONParserContext { Error *err; @@ -538,6 +545,18 @@ static QObject *parse_value(JSONParserContext *ctxt, v= a_list *ap) } } =20 +JSONToken *json_token(JSONTokenType type, int x, int y, GString *tokstr) +{ + JSONToken *token =3D g_malloc(sizeof(JSONToken) + tokstr->len + 1); + + token->type =3D type; + memcpy(token->str, tokstr->str, tokstr->len); + token->str[tokstr->len] =3D 0; + token->x =3D x; + token->y =3D y; + return token; +} + QObject *json_parser_parse(GQueue *tokens, va_list *ap, Error **errp) { JSONParserContext ctxt =3D { .buf =3D tokens }; diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c index 9210281a65..467bc29413 100644 --- a/qobject/json-streamer.c +++ b/qobject/json-streamer.c @@ -82,13 +82,7 @@ void json_message_process_token(JSONLexer *lexer, GStrin= g *input, goto out_emit; } =20 - token =3D g_malloc(sizeof(JSONToken) + input->len + 1); - token->type =3D type; - memcpy(token->str, input->str, input->len); - token->str[input->len] =3D 0; - token->x =3D x; - token->y =3D y; - + token =3D json_token(type, x, y, input); parser->token_size +=3D input->len; =20 g_queue_push_tail(&parser->tokens, token); --=20 2.17.1