All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: berrange@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 1/2] qemu-option: move help handling to get_opt_name_value
Date: Fri, 06 Nov 2020 17:55:13 +0100	[thread overview]
Message-ID: <878sbee87i.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <87eel6ikrm.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Fri, 06 Nov 2020 16:10:21 +0100")

One more thought...

Markus Armbruster <armbru@redhat.com> writes:

> Paolo Bonzini <pbonzini@redhat.com> writes:
[...]
>> diff --git a/util/qemu-option.c b/util/qemu-option.c
[...]
>> @@ -767,16 +763,18 @@ void qemu_opts_print(QemuOpts *opts, const char *separator)
>>  
>>  static const char *get_opt_name_value(const char *params,
>>                                        const char *firstname,
>> +                                      bool *help_wanted,
>>                                        char **name, char **value)
>>  {
>> -    const char *p, *pe, *pc;
>> -
>> -    pe = strchr(params, '=');
>> -    pc = strchr(params, ',');
>> +    const char *p;
>> +    size_t len;
>>  
>> -    if (!pe || (pc && pc < pe)) {
>> +    len = strcspn(params, "=,");
>> +    if (params[len] != '=') {
>>          /* found "foo,more" */
>> -        if (firstname) {
>> +        if (help_wanted && starts_with_help_option(params) == len) {
>> +            *help_wanted = true;
>> +        } else if (firstname) {
>>              /* implicitly named first option */
>>              *name = g_strdup(firstname);
>>              p = get_opt_value(params, value);
>
> This function parses one parameter from @params into @name, @value, and
> returns a pointer to the next parameter, or else to the terminating
> '\0'.

Like opt_validate() before, this sets *help_wanted only to true.
Callers must pass a pointer to false.  Perhaps having it set
*help_wanted always could simplify things overall.  Up to you.

[...]



  reply	other threads:[~2020-11-06 16:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-05 14:27 [PATCH for-5.2 0/2] deprecate short-form boolean options Paolo Bonzini
2020-11-05 14:27 ` [PATCH 1/2] qemu-option: move help handling to get_opt_name_value Paolo Bonzini
2020-11-06 15:10   ` Markus Armbruster
2020-11-06 16:55     ` Markus Armbruster [this message]
2020-11-05 14:27 ` [PATCH 2/2] qemu-option: warn for short-form boolean options Paolo Bonzini
2020-11-06 16:49   ` Markus Armbruster
2020-11-06 18:20     ` Paolo Bonzini
2020-11-09  7:59       ` Markus Armbruster
2020-11-05 14:36 ` [PATCH for-5.2 0/2] deprecate " no-reply

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=878sbee87i.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.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.