[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that bre
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that break qapi-event.py |
Date: |
Mon, 20 Jul 2015 11:57:53 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 07/01/2015 02:21 PM, Markus Armbruster wrote:
> qapi-event.py breaks when you ask for a funny prefix like '@'.
> Protect it.
Only possible from the command line (not triggered by our makefiles);
but doesn't hurt.
>
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
> scripts/qapi.py | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 2bbc8ff..ea94ce5 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1003,6 +1003,12 @@ def parse_command_line(extra_options = "",
> extra_long_options = []):
> for oa in opts:
> o, a = oa
> if o in ("-p", "--prefix"):
> + match = re.match('([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
I can understand allowing a leading _, but why bother allowing a leading
'.' or '-'? Those will get normalized to _, but in all honesty, no one
should ever be doing that.
I'd be just as happy with the shorter:
match = re.match('([A-Za-z_][A-Za-z0-9_.-]*)?', a)
> + if match.end() != len(a):
> + print >>sys.stderr, \
> + "%s: 'funny character '%s' in argument of -prefix" \
'qemu' is unusual for accepting -single-dash-long-opts; I don't think
python getopts does the same by default. Please spell this error
message --prefix.
> + % (sys.argv[0], a[match.end()])
> + sys.exit(1)
> prefix = a
> elif o in ("-o", "--output-dir"):
> output_dir = a + "/"
>
With the second spelling fix, and optionally with the shorter regex,
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH RFC v2 02/47] qapi: Clean up cgen() and mcgen(), (continued)
- [Qemu-devel] [PATCH RFC v2 02/47] qapi: Clean up cgen() and mcgen(), Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 09/47] qapi-visit: Replace list implicit_structs by set, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 07/47] qapi: Generate a nicer struct for flat unions, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 01/47] qapi: Clarify docs on including the same file multiple times, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that break qapi-event.py, Markus Armbruster, 2015/07/01
- Re: [Qemu-devel] [PATCH RFC v2 05/47] qapi: Reject -p arguments that break qapi-event.py,
Eric Blake <=
- [Qemu-devel] [PATCH RFC v2 10/47] qapi-visit: Fix two name arguments passed to visitors, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 11/47] tests/qapi-schema: Document alternate's enum lacks visit function, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 13/47] tests/qapi-schema: Restore test case for flat union base bug, Markus Armbruster, 2015/07/01
- [Qemu-devel] [PATCH RFC v2 16/47] qapi-commands: Fix gen_err_check(e) for e and e != 'local_err', Markus Armbruster, 2015/07/01