From: David Hildenbrand <david@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [Qemu-devel] [PATCH v3 1/7] qapi: use qemu_strtoi64() in parse_str
Date: Thu, 8 Nov 2018 15:46:34 +0100 [thread overview]
Message-ID: <32eda606-79b8-5805-e61f-06741eddb2cc@redhat.com> (raw)
In-Reply-To: <877ehnmyak.fsf@dusky.pond.sub.org>
On 08.11.18 15:36, Markus Armbruster wrote:
> David Hildenbrand <david@redhat.com> writes:
>
>> I found some more ugliness, looking at the tests. I am not sure the test
>> is correct here.
>>
>> test_visitor_in_intList():
>>
>> v = visitor_input_test_init(data, "1,2,0,2-4,20,5-9,1-8");
>>
>> -> we expect { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 }, implying that the
>> visitor actually does sorting + duplicate elimination. Now I consider
>> this is wrong. We are parsing a list of integers, not an ordered set.
>>
>> What's your take on this?
>
> I think you're right. Visitors are tied to QAPI, and QAPI does *lists*,
> not sets. Lists are more general than sets.
>
> I figure what drove development of this code was a need for sets, so
> sets got implemented. Review fail.
>
> If the visitor does lists, whatever needs sets can convert the lists to
> sets.
>
> I'd advise against evolving the current code towards sanity. Instead,
> rewrite, and rely on tests to avoid unwanted changes in behavior.
>
With the current rewrite I have, I can parse uint64 and int64 lists. The
other types will bail out if lists are used right now.
The changes that have to be done to the tests are:
diff --git a/tests/test-string-input-visitor.c
b/tests/test-string-input-visitor.c
index 88e0e1aa9a..5d2d707e80 100644
--- a/tests/test-string-input-visitor.c
+++ b/tests/test-string-input-visitor.c
@@ -92,16 +92,6 @@ static void check_ulist(Visitor *v, uint64_t
*expected, size_t n)
uint64List *tail;
int i;
- /* BUG: unsigned numbers above INT64_MAX don't work */
- for (i = 0; i < n; i++) {
- if (expected[i] > INT64_MAX) {
- Error *err = NULL;
- visit_type_uint64List(v, NULL, &res, &err);
- error_free_or_abort(&err);
- return;
- }
- }
-
visit_type_uint64List(v, NULL, &res, &error_abort);
tail = res;
for (i = 0; i < n; i++) {
@@ -118,9 +108,9 @@ static void
test_visitor_in_intList(TestInputVisitorData *data,
const void *unused)
{
- /* Note: the visitor *sorts* ranges *unsigned* */
- int64_t expect1[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 20 };
+ int64_t expect1[] = { 1, 2, 0, 2, 3, 4, 20, 5, 6, 7, 8, 9, 1, 2, 3,
4, 5, 6, 7, 8 };
int64_t expect2[] = { 32767, -32768, -32767 };
- int64_t expect3[] = { INT64_MAX, INT64_MIN };
+ int64_t expect3[] = { INT64_MIN, INT64_MAX };
uint64_t expect4[] = { UINT64_MAX };
Error *err = NULL;
int64List *res = NULL;
@@ -189,7 +179,7 @@ static void
test_visitor_in_intList(TestInputVisitorData *data,
visit_type_int64(v, NULL, &tail->value, &err);
g_assert_cmpint(tail->value, ==, 0);
visit_type_int64(v, NULL, &val, &err);
- g_assert_cmpint(val, ==, 1); /* BUG */
+ error_free_or_abort(&err);
visit_check_list(v, &error_abort);
visit_end_list(v, (void **)&res);
Basically fixing two bugs (yey, let's make our tests pass by hardcoding
BUG behavior, so the actually fixed code will break them)
And converting two assumptions about ordered sets into unordered lists.
(using unsigned ranges for handling signed ranges is completely broken,
as can also be seen via the removed "Note:")
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2018-11-08 14:46 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-23 15:22 [Qemu-devel] [PATCH v3 0/7] qapi/range/memory-device: fixes and cleanups David Hildenbrand
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 1/7] qapi: use qemu_strtoi64() in parse_str David Hildenbrand
2018-10-25 14:37 ` David Gibson
2018-10-31 14:40 ` Markus Armbruster
2018-10-31 16:47 ` David Hildenbrand
2018-10-31 17:55 ` Markus Armbruster
2018-10-31 18:01 ` David Hildenbrand
2018-11-05 15:37 ` Markus Armbruster
2018-11-05 15:53 ` David Hildenbrand
2018-11-05 16:48 ` Eric Blake
2018-11-06 9:20 ` David Hildenbrand
2018-11-05 20:43 ` Markus Armbruster
2018-11-06 9:19 ` David Hildenbrand
2018-11-07 15:29 ` Markus Armbruster
2018-11-07 20:02 ` David Hildenbrand
2018-11-08 8:39 ` Markus Armbruster
2018-11-08 8:54 ` David Hildenbrand
2018-11-08 9:13 ` Markus Armbruster
2018-11-08 13:05 ` David Hildenbrand
2018-11-08 14:36 ` Markus Armbruster
2018-11-08 14:46 ` David Hildenbrand [this message]
2018-11-08 14:42 ` Eric Blake
2018-11-08 14:49 ` David Hildenbrand
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 2/7] qapi: correctly parse uint64_t values from strings David Hildenbrand
2018-10-25 14:41 ` David Gibson
2018-10-26 12:48 ` David Hildenbrand
2018-10-31 14:32 ` Markus Armbruster
2018-10-31 14:44 ` Markus Armbruster
2018-10-31 17:19 ` David Hildenbrand
2018-10-31 17:18 ` David Hildenbrand
2018-11-04 3:27 ` David Gibson
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 3/7] range: pass const pointer where possible David Hildenbrand
2018-10-25 14:41 ` David Gibson
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 4/7] range: add some more functions David Hildenbrand
2018-11-01 10:00 ` Igor Mammedov
2018-11-01 10:29 ` David Hildenbrand
2018-11-01 11:05 ` Igor Mammedov
2018-11-05 10:30 ` David Hildenbrand
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 5/7] memory-device: use QEMU_IS_ALIGNED David Hildenbrand
2018-10-25 14:44 ` David Gibson
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 6/7] memory-device: avoid overflows on very huge devices David Hildenbrand
2018-10-25 14:44 ` David Gibson
2018-10-25 14:45 ` Igor Mammedov
2018-10-23 15:23 ` [Qemu-devel] [PATCH v3 7/7] memory-device: rewrite address assignment using ranges David Hildenbrand
2018-11-12 14:07 ` David Hildenbrand
2018-11-13 12:26 ` Igor Mammedov
2018-11-13 12:41 ` David Hildenbrand
2018-11-13 13:01 ` [Qemu-devel] [PATCH v4] " David Hildenbrand
2018-10-31 10:14 ` [Qemu-devel] [PATCH v3 0/7] qapi/range/memory-device: fixes and cleanups David Hildenbrand
2018-10-31 19:43 ` Eduardo Habkost
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=32eda606-79b8-5805-e61f-06741eddb2cc@redhat.com \
--to=david@redhat.com \
--cc=armbru@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=mst@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).