From: Michal Privoznik <mprivozn@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v4 2/3] watchdog.h: Drop local redefinition of actions enum
Date: Thu, 7 Sep 2017 09:56:24 +0200 [thread overview]
Message-ID: <cd13f335-e1ae-b340-61e5-06a7bc78881f@redhat.com> (raw)
In-Reply-To: <87zia7rb6h.fsf@dusky.pond.sub.org>
On 09/06/2017 07:25 PM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
>
>> On 09/06/2017 06:24 AM, Michal Privoznik wrote:
>>> We already have enum that enumerates all the action that a
>>
>> s/action/actions/
>>
>>> watchdog can take when hitting its timeout: WatchdogAction.
>>> Use that instead of inventing our own.
>>>
>>> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>>> ---
>>
>>> @@ -77,27 +77,16 @@ int select_watchdog(const char *p)
>>>
>>> int select_watchdog_action(const char *p)
>>> {
>>> - if (strcasecmp(p, "reset") == 0)
>>> - watchdog_action = WDT_RESET;
>>
>> The old code was case-insensitive,
>>
>>> + action = qapi_enum_parse(&WatchdogAction_lookup, p, -1, NULL);
>>
>> the new code is not. Do we care? (I don't, but we could be breaking
>> someone's control flow). Should qapi_enum_parse be taught to be
>> case-insensitive? Or perhaps we answer related questions first: Do we
>> have any QAPI enums that have values differing only in case? Do we
>> prevent such QAPI definitions, to give us the potential of making the
>> parsing insensitive?
>
> Case-sensitive everywhere is fine. Case-insensitive everywhere also
> fine, just not my personal preference. What's not fine is "guess
> whether this part of the interface is case-sensitive or not".
>
> QMP is case-sensitive. Let's keep it that way.
>
> The -watchdog-action option has a case-insensitive argument. The
> obvious way to remain misfeature-^Wbackwards compatible is converting
> the argument to lower case before handing it off to qapi_enum_parse. I
> doubt it matters, but just doing it is less work than debating how far
> exactly we want to bend over backwards.
>
> g_ascii_strdown() should do. It only converts ASCII characters, but
> anything else is going to fail in qapi_enum_parse() anyway.
>
On the other hand, the documentation enumerates the accepted values in
lowercase. So one can argue that upper- or mixed-case is just a misuse
of a bug in the code. But getting the code in is more important to me so
I'll do the strdown() conversion and sent yet another version.
Michal
next prev parent reply other threads:[~2017-09-07 7:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-06 11:24 [Qemu-devel] [PATCH v4 0/3] watchdog: Allow setting action on the fly Michal Privoznik
2017-09-06 11:24 ` [Qemu-devel] [PATCH v4 1/3] qapi: Rename WatchdogExpirationAction enum Michal Privoznik
2017-09-06 15:34 ` Eric Blake
2017-09-06 11:24 ` [Qemu-devel] [PATCH v4 2/3] watchdog.h: Drop local redefinition of actions enum Michal Privoznik
2017-09-06 15:37 ` Eric Blake
2017-09-06 17:25 ` Markus Armbruster
2017-09-07 7:56 ` Michal Privoznik [this message]
2017-09-07 9:02 ` Markus Armbruster
2017-09-06 11:24 ` [Qemu-devel] [PATCH v4 3/3] watchdog: Allow setting action on the fly Michal Privoznik
2017-09-06 15:39 ` Eric Blake
2017-09-06 17:15 ` Markus Armbruster
2017-09-06 15:32 ` [Qemu-devel] [PATCH v4 0/3] " Markus Armbruster
2017-09-06 15:37 ` Richard W.M. Jones
2017-09-06 15:41 ` Michal Privoznik
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=cd13f335-e1ae-b340-61e5-06a7bc78881f@redhat.com \
--to=mprivozn@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@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).