From nobody Wed Nov 5 23:00:02 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 1537806343197593.120362067681; Mon, 24 Sep 2018 09:25:43 -0700 (PDT) Received: from localhost ([::1]:46044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4Tg6-0007VM-4M for importer@patchew.org; Mon, 24 Sep 2018 12:25:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34763) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4Taq-0002sC-Aw for qemu-devel@nongnu.org; Mon, 24 Sep 2018 12:20:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4Tap-0004Uf-Eq for qemu-devel@nongnu.org; Mon, 24 Sep 2018 12:20:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g4Tap-0004UG-8u for qemu-devel@nongnu.org; Mon, 24 Sep 2018 12:20:15 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A294E81DF7 for ; Mon, 24 Sep 2018 16:20:14 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-98.ams2.redhat.com [10.36.116.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E1E02010D95 for ; Mon, 24 Sep 2018 16:20:13 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 63D0B11385CB; Mon, 24 Sep 2018 18:20:07 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 24 Sep 2018 18:20:06 +0200 Message-Id: <20180924162007.3084-6-armbru@redhat.com> In-Reply-To: <20180924162007.3084-1-armbru@redhat.com> References: <20180924162007.3084-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Sep 2018 16:20:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/6] json: Eliminate lexer state IN_ERROR 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: , 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 Message-Id: <20180831075841.13363-6-armbru@redhat.com> --- qobject/json-lexer.c | 9 +++++---- qobject/json-parser-int.h | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qobject/json-lexer.c b/qobject/json-lexer.c index 39c7ce7adc..2a5561c917 100644 --- a/qobject/json-lexer.c +++ b/qobject/json-lexer.c @@ -100,8 +100,7 @@ */ =20 enum json_lexer_state { - IN_ERROR =3D 0, /* must really be 0, see json_lexer[] */ - IN_RECOVERY, + IN_RECOVERY =3D 1, IN_DQ_STRING_ESCAPE, IN_DQ_STRING, IN_SQ_STRING_ESCAPE, @@ -121,6 +120,8 @@ enum json_lexer_state { IN_START_INTERP, /* must be IN_START + 1 */ }; =20 +QEMU_BUILD_BUG_ON(JSON_ERROR !=3D 0); +QEMU_BUILD_BUG_ON(IN_RECOVERY !=3D JSON_ERROR + 1); QEMU_BUILD_BUG_ON((int)JSON_MIN <=3D (int)IN_START_INTERP); QEMU_BUILD_BUG_ON(JSON_MAX >=3D 0x80); QEMU_BUILD_BUG_ON(IN_START_INTERP !=3D IN_START + 1); @@ -176,7 +177,7 @@ static const uint8_t json_lexer[][256] =3D { /* Zero */ [IN_ZERO] =3D { TERMINAL(JSON_INTEGER), - ['0' ... '9'] =3D IN_ERROR, + ['0' ... '9'] =3D JSON_ERROR, ['.'] =3D IN_MANTISSA, }, =20 @@ -328,7 +329,7 @@ static void json_lexer_feed_char(JSONLexer *lexer, char= ch, bool flush) case IN_START: new_state =3D lexer->start_state; break; - case IN_ERROR: + case JSON_ERROR: json_message_process_token(lexer, lexer->token, JSON_ERROR, lexer->x, lexer->y); new_state =3D IN_RECOVERY; diff --git a/qobject/json-parser-int.h b/qobject/json-parser-int.h index abeec63af5..57cb8e79d3 100644 --- a/qobject/json-parser-int.h +++ b/qobject/json-parser-int.h @@ -16,10 +16,11 @@ =20 #include "qapi/qmp/json-parser.h" =20 - typedef enum json_token_type { - JSON_MIN =3D 100, - JSON_LCURLY =3D JSON_MIN, + JSON_ERROR =3D 0, /* must be zero, see json_lexer[] */ + /* Gap for lexer states */ + JSON_LCURLY =3D 100, + JSON_MIN =3D JSON_LCURLY, JSON_RCURLY, JSON_LSQUARE, JSON_RSQUARE, @@ -31,7 +32,6 @@ typedef enum json_token_type { JSON_STRING, JSON_INTERP, JSON_SKIP, - JSON_ERROR, JSON_END_OF_INPUT, JSON_MAX =3D JSON_END_OF_INPUT } JSONTokenType; --=20 2.17.1