From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 1/6] qemu-option: has_help_option() and is_valid_option_list()
Date: Fri, 21 Feb 2014 21:57:55 +0100 [thread overview]
Message-ID: <20140221205755.GD3346@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <5307B593.7020801@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2041 bytes --]
Am 21.02.2014 um 21:22 hat Eric Blake geschrieben:
> On 02/21/2014 08:24 AM, Kevin Wolf wrote:
> > has_help_option() checks if any help option ('help' or '?') occurs
> > anywhere in an option string, so that things like 'cluster_size=4k,help'
> > are recognised.
> >
> > is_valid_option_list() ensures that the option list doesn't have options
> > with leading commas or trailing unescaped commas.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
>
> > +
> > + while (*p) {
> > + p = get_opt_value(buf, buflen, p);
> > + if (*p) {
> > + p++;
> > + }
> > +
> > + if (is_help_option(buf)) {
> > + result = true;
> > + goto out;
>
> If this were 'break;',
>
> > + }
> > + }
> > +
> > +out:
>
> then you wouldn't need this label. But that's cosmetic.
>
> > + free(buf);
> > + return result;
> > +}
> > +
> > +bool is_valid_option_list(const char *param)
> > +{
> > + size_t buflen = strlen(param) + 1;
> > + char *buf = g_malloc0(buflen);
> > + const char *p = param;
> > + bool result = true;
> > +
> > + while (*p) {
> > + p = get_opt_value(buf, buflen, p);
> > + if (*p && !*++p) {
> > + result = false;
> > + goto out;
> > + }
>
> Rejects trailing commas.
>
> > +
> > + if (!*buf || *buf == ',') {
>
> Rejects empty options, but also rejects values beginning with a comma.
> But we have legacy users that accept implicitly named first options (see
> opts_do_parse()). For example, this is a valid command line (albeit one
> that prints a list of valid machines):
>
> qemu-kvm -machine ,,blah
>
> as shorthand for
>
> qemu-kvm -machine type=,,blah
>
> and where *buf would indeed be validly ','.
Right, but I can't allow this without allowing '-o ,,' which breaks the
real use case. So the lesson is that you can concatenate option strings
and use implicit option names at the same time.
Kevin
[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2014-02-21 20:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 15:24 [Qemu-devel] [PATCH v3 0/6] qemu-img: Support multiple -o options Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 1/6] qemu-option: has_help_option() and is_valid_option_list() Kevin Wolf
2014-02-21 20:22 ` Eric Blake
2014-02-21 20:57 ` Kevin Wolf [this message]
2014-02-24 8:42 ` Markus Armbruster
2014-02-24 9:42 ` Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 2/6] qemu-img create: Support multiple -o options Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 3/6] qemu-img convert: " Kevin Wolf
2014-03-03 11:43 ` Peter Lieven
2014-03-03 13:08 ` Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 4/6] qemu-img amend: " Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 5/6] qemu-img: Allow -o help with incomplete argument list Kevin Wolf
2014-02-21 15:24 ` [Qemu-devel] [PATCH v3 6/6] qemu-iotests: Check qemu-img command line parsing Kevin Wolf
2014-02-21 20:38 ` Eric Blake
2014-02-21 19:59 ` [Qemu-devel] [PATCH v3 0/6] qemu-img: Support multiple -o options Jeff Cody
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=20140221205755.GD3346@dhcp-200-207.str.redhat.com \
--to=kwolf@redhat.com \
--cc=eblake@redhat.com \
--cc=jcody@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).