|
From: | Paolo Bonzini |
Subject: | Re: [PATCH v2 5/6] qemu-option: move help handling to get_opt_name_value |
Date: | Mon, 9 Nov 2020 20:47:35 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 |
On 09/11/20 20:40, Markus Armbruster wrote:
+ p = get_opt_name_value(p, firstname, help_wanted, &option, &value); + if (help_wanted && *help_wanted) { + return false;Doesn't this leak @option and @value? Remember, [2] get_opt_name_value() always sets *name and *value.
Yes, it does. :(
if (help_wanted) { qemu_opts_print_help(list, true); - error_free(err); } else { error_report_err(err); }I think we could pass &help_wanted unconditionally, then ignore the value of help_wanted if opts_accepts_any().
Unfortunately not, because callers rely on "help" being added to the options for !opts_accepts_any. opts_do_parse however does:
+ if (help_wanted && *help_wanted) { + return false; + }
You made the same remark on the previous version, but unfortunately I couldn't make it actually produce simpler code.
Paolo
[Prev in Thread] | Current Thread | [Next in Thread] |