From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL v3 for-2.9 12/17] qapi: Fix string input visitor regression for empty lists
Date: Wed, 22 Mar 2017 19:36:16 +0100 [thread overview]
Message-ID: <1490207781-18965-13-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1490207781-18965-1-git-send-email-armbru@redhat.com>
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 <armbru@redhat.com>
Message-Id: <1490026424-11330-2-git-send-email-armbru@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
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;
}
+ if (!*str) {
+ return 0;
+ }
+
do {
errno = 0;
start = strtoll(str, &endptr, 0);
diff --git a/tests/test-string-input-visitor.c b/tests/test-string-input-visitor.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 *data,
visit_type_int(v, NULL, &res, &err);
error_free_or_abort(&err);
+
+ v = visitor_input_test_init(data, "");
+
+ visit_type_int(v, NULL, &res, &err);
+ error_free_or_abort(&err);
}
static void check_ilist(Visitor *v, int64_t *expected, size_t n)
@@ -140,11 +145,11 @@ static void test_visitor_in_intList(TestInputVisitorData *data,
v = visitor_input_test_init(data, "18446744073709551615");
check_ulist(v, expect4, ARRAY_SIZE(expect4));
- /* Empty list is invalid (weird) */
+ /* Empty list */
v = 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);
/* Not a list */
--
2.7.4
next prev parent reply other threads:[~2017-03-22 18:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-22 18:36 [Qemu-devel] [PULL v3 for-2.9 00/17] QAPI patches for 2017-03-22 Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 01/17] test-keyval: Tweaks to improve list coverage Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 02/17] keyval: Improve some comments Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 03/17] test-keyval: Cover alternate and 'any' type Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 04/17] keyval: Document issues with 'any' and alternate types Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 05/17] MAINTAINERS: Add myself for files I touched recently Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 06/17] qapi: Drop excessive Make dependencies on qapi2texi.py Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 07/17] qapi2texi: Fix to actually fail when 'doc-required' is false Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 08/17] qapi: Drop unused QAPIDoc member optional Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 09/17] tests/qapi-schema: Make test-qapi.py print docs again Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 10/17] tests/qapi-schema: Systematic positive doc comment tests Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 11/17] qapi2texi: Fix translation of *strong* and _emphasized_ Markus Armbruster
2017-03-22 18:36 ` Markus Armbruster [this message]
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 13/17] Revert "hostmem: fix QEMU crash by 'info memdev'" Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 14/17] test-qobject-input-visitor: Cover visit_type_uint64() Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 15/17] tests: Expose regression in QemuOpts visitor Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 16/17] qom: Avoid unvisited 'id'/'qom-type' in user_creatable_add_opts Markus Armbruster
2017-03-22 18:36 ` [Qemu-devel] [PULL v3 for-2.9 17/17] qapi: Fix QemuOpts visitor regression on unvisited input Markus Armbruster
2017-03-23 13:43 ` [Qemu-devel] [PULL v3 for-2.9 00/17] QAPI patches for 2017-03-22 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1490207781-18965-13-git-send-email-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).