From nobody Sat Feb 7 07:09:54 2026 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1490199467239658.2704168278993; Wed, 22 Mar 2017 09:17:47 -0700 (PDT) Received: from localhost ([::1]:52043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqixF-00086U-VZ for importer@patchew.org; Wed, 22 Mar 2017 12:17:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cqilp-0006XY-02 for qemu-devel@nongnu.org; Wed, 22 Mar 2017 12:05:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cqilk-0001jZ-Vs for qemu-devel@nongnu.org; Wed, 22 Mar 2017 12:05:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38514) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cqilk-0001iI-GE for qemu-devel@nongnu.org; Wed, 22 Mar 2017 12:05:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8914D7E9C7 for ; Wed, 22 Mar 2017 16:05:52 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-26.ams2.redhat.com [10.36.116.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55A7D800D1 for ; Wed, 22 Mar 2017 16:05:52 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6292D1138617; Wed, 22 Mar 2017 17:05:48 +0100 (CET) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8914D7E9C7 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 8914D7E9C7 From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 22 Mar 2017 17:05:43 +0100 Message-Id: <1490198748-4753-13-git-send-email-armbru@redhat.com> In-Reply-To: <1490198748-4753-1-git-send-email-armbru@redhat.com> References: <1490198748-4753-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 22 Mar 2017 16:05:52 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.9 12/17] qapi: Fix string input visitor regression for empty lists 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: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Visiting a list when input is the empty string should result in an empty list, not an error. Noticed when commit 3d089ce belatedly added tests, but simply accepted as weird then. It's actually a regression: broken in commit 74f24cb, v2.7.0. Fix it, and throw in another test case for empty string. Signed-off-by: Markus Armbruster Message-Id: <1490026424-11330-2-git-send-email-armbru@redhat.com> Reviewed-by: Michael Roth Reviewed-by: Eric Blake --- qapi/string-input-visitor.c | 4 ++++ tests/test-string-input-visitor.c | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index 806b01ae..c089491 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -54,6 +54,10 @@ static int parse_str(StringInputVisitor *siv, const char= *name, Error **errp) return 0; } =20 + if (!*str) { + return 0; + } + do { errno =3D 0; start =3D strtoll(str, &endptr, 0); diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-vi= sitor.c index 6db850b..79313a7 100644 --- a/tests/test-string-input-visitor.c +++ b/tests/test-string-input-visitor.c @@ -63,6 +63,11 @@ static void test_visitor_in_int(TestInputVisitorData *da= ta, =20 visit_type_int(v, NULL, &res, &err); error_free_or_abort(&err); + + v =3D visitor_input_test_init(data, ""); + + visit_type_int(v, NULL, &res, &err); + error_free_or_abort(&err); } =20 static void check_ilist(Visitor *v, int64_t *expected, size_t n) @@ -140,11 +145,11 @@ static void test_visitor_in_intList(TestInputVisitorD= ata *data, v =3D visitor_input_test_init(data, "18446744073709551615"); check_ulist(v, expect4, ARRAY_SIZE(expect4)); =20 - /* Empty list is invalid (weird) */ + /* Empty list */ =20 v =3D visitor_input_test_init(data, ""); - visit_type_int64List(v, NULL, &res, &err); - error_free_or_abort(&err); + visit_type_int64List(v, NULL, &res, &error_abort); + g_assert(!res); =20 /* Not a list */ =20 --=20 2.7.4