[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] qemu-option: move help handling to get_opt_name_value
From: |
Markus Armbruster |
Subject: |
Re: [PATCH 1/2] qemu-option: move help handling to get_opt_name_value |
Date: |
Fri, 06 Nov 2020 17:55:13 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
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.
[...]