All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH RFC 3/6] qapi: rewrite string-input-visitor
Date: Thu, 15 Nov 2018 11:16:48 +0100	[thread overview]
Message-ID: <ef7b64f3-d7f3-6892-e0f3-f4e605604225@redhat.com> (raw)
In-Reply-To: <87tvkiisdi.fsf@dusky.pond.sub.org>

On 15.11.18 10:48, Markus Armbruster wrote:
> David Hildenbrand <david@redhat.com> writes:
> 
>> On 14.11.18 18:38, Markus Armbruster wrote:
>>> David Hildenbrand <david@redhat.com> writes:
>>>
>>>> The input visitor has some problems right now, especially
>>>> - unsigned type "Range" is used to process signed ranges, resulting in
>>>>   inconsistent behavior and ugly/magical code
>>>> - uint64_t are parsed like int64_t, so big uint64_t values are not
>>>>   supported and error messages are misleading
>>>> - lists/ranges of int64_t are accepted although no list is parsed and
>>>>   we should rather report an error
>>>> - lists/ranges are preparsed using int64_t, making it hard to
>>>>   implement uint64_t values or uint64_t lists
>>>> - types that don't support lists don't bail out
>>>
>>> Known weirdness: empty list is invalid (test-string-input-visitor.c
>>> demonstates).  Your patch doesn't change that (or else it would update
>>> the test).  Should it be changed?
>>>
>>
>> I don't change the test, so the old behavior still works.
>> (empty string -> error)
> 
> Understand.  Design question: should it remain an error?  Feel free to
> declare the question out of scope for this patch.

I think I was confused, let me retry to explain.

Empty lists actually don't result in an error. Calling start_list() on
an empty string works just fine.

However
- check_list() will result in "Fewer list elements expected"
- visit_type_.*int64() will result in "Fewer list elements expected"
- next_list() will result in NULL

I guess that is the intended behavior. E.g. the test does

v = visitor_input_test_init(data, "");
visit_type_uint64List(v, NULL, &res, &error_abort);
g_assert(!res);

So there won't be any error as the first "visit_next_list()" will
properly indicate "NULL".


>> Added "Only flat lists of integers (int64/uint64) are supported."
> 
> Hmm, do lists of narrower integer types also work?  I guess they do: the
> narrower visit_type_*int*() call v->type_*int64() via
> visit_type_*intN().
> 
> Lists of type size are expressly excluded, in parse_type_size() below.
> That's okay, we can lift the restriction when it gets in the way.

Right, we can make that clearer

"Only flat lists of integers (except type "size") are supported." ?
[...]

> 
>> What about "Less list elements expected"? That at least matches the
>> other error.
> 
> Good enough.  I'd say "fewer", though.

Fine with me!
[...]
>>>> +        return;
>>>> +    case LM_UNPARSED:
>>>> +        if (try_parse_int64_list_entry(siv, obj)) {
>>>> +            error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",
>>>> +                       "list of int64 values or ranges");
>>>> +        }
>>>
>>> I figure I'd make try_parse_int64_list_entry() just parse, and on
>>> success fall through to case LM_INT64_RANGE.  But your solution works,
>>> too.
>>
>> Then we would have to represent even single values as ranges, which is
>> something I'd like to avoid.
> 
> Your artistic license applies.

It actually looks nicer your way (and seems to be less error prone).
Stay tuned!

-- 

Thanks,

David / dhildenb

  reply	other threads:[~2018-11-15 10:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-09 11:02 [Qemu-devel] [PATCH RFC 0/6] qapi: rewrite string-input-visitor David Hildenbrand
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 1/6] cutils: add qemu_strtod() David Hildenbrand
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 2/6] qapi: use qemu_strtod() in string-input-visitor David Hildenbrand
2018-11-14 16:09   ` Markus Armbruster
2018-11-15 11:09     ` David Hildenbrand
2018-11-15 13:17       ` Eric Blake
2018-11-15 13:54         ` David Hildenbrand
2018-11-15 14:43         ` Markus Armbruster
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 3/6] qapi: rewrite string-input-visitor David Hildenbrand
2018-11-14 17:38   ` Markus Armbruster
2018-11-14 19:56     ` David Hildenbrand
2018-11-15  9:48       ` Markus Armbruster
2018-11-15 10:16         ` David Hildenbrand [this message]
2018-11-15 14:57           ` Markus Armbruster
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 4/6] test-string-input-visitor: use virtual walk David Hildenbrand
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 5/6] test-string-input-visitor: split off uint64 list tests David Hildenbrand
2018-11-14 16:21   ` Markus Armbruster
2018-11-14 20:03     ` David Hildenbrand
2018-11-15  9:59       ` Markus Armbruster
2018-11-09 11:02 ` [Qemu-devel] [PATCH RFC 6/6] test-string-input-visitor: add range overflow tests David Hildenbrand

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=ef7b64f3-d7f3-6892-e0f3-f4e605604225@redhat.com \
    --to=david@redhat.com \
    --cc=armbru@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=pbonzini@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.