[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number n
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v13 2/6] option: make parse_option_bool/number non-static |
Date: |
Fri, 23 Sep 2016 12:24:30 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 19.09.2016 um 13:58 hat Daniel P. Berrange geschrieben:
> The opts-visitor.c opts_type_bool() method has code for
> parsing a string to set a bool value, as does the
> qemu-option.c parse_option_bool() method, except it
> handles fewer cases.
>
> To enable consistency across the codebase, extend
> parse_option_bool() to handle "yes", "no", "y" and
> "n", and make it non-static. Convert the opts
> visitor to call this method directly.
>
> Also make parse_option_number() non-static to allow
> for similar reuse later.
>
> Reviewed-by: Kevin Wolf <address@hidden>
> Reviewed-by: Marc-André Lureau <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> --- a/util/qemu-option.c
> +++ b/util/qemu-option.c
> @@ -125,25 +125,30 @@ int get_param_value(char *buf, int buf_size,
> return get_next_param_value(buf, buf_size, tag, &str);
> }
>
> -static void parse_option_bool(const char *name, const char *value, bool *ret,
> - Error **errp)
> +void parse_option_bool(const char *name, const char *value, bool *ret,
> + Error **errp)
> {
> if (value != NULL) {
> - if (!strcmp(value, "on")) {
> - *ret = 1;
> - } else if (!strcmp(value, "off")) {
> - *ret = 0;
> + if (strcmp(value, "on") == 0 ||
> + strcmp(value, "yes") == 0 ||
> + strcmp(value, "y") == 0) {
> + *ret = true;
> + } else if (strcmp(value, "off") == 0 ||
> + strcmp(value, "no") == 0 ||
> + strcmp(value, "n") == 0) {
> + *ret = false;
> } else {
> - error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
> - name, "'on' or 'off'");
> + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name,
> + "on|yes|y|off|no|n");
This change requires an update to the reference output of some
qemu-iotests (at least 051 and 137).
Kevin
[Qemu-devel] [PATCH v13 1/6] qdict: implement a qdict_crumple method for un-flattening a dict, Daniel P. Berrange, 2016/09/19
[Qemu-devel] [PATCH v13 3/6] qapi: rename QmpInputVisitor to QObjectInputVisitor, Daniel P. Berrange, 2016/09/19
[Qemu-devel] [PATCH v13 5/6] qapi: add a QObjectInputVisitor that does string conversion, Daniel P. Berrange, 2016/09/19
[Qemu-devel] [PATCH v13 4/6] qapi: rename QmpOutputVisitor to QObjectOutputVisitor, Daniel P. Berrange, 2016/09/19
[Qemu-devel] [PATCH v13 6/6] qom: support arbitrary non-scalar properties with -object, Daniel P. Berrange, 2016/09/19