From: Greg Kurz <groug@kaod.org>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: clg@kaod.org, aik@ozlabs.ru, mdroth@linux.vnet.ibm.com,
nikunj@linux.vnet.ibm.com, qemu-devel@nongnu.org,
armbru@redhat.com, qemu-ppc@nongnu.org, abologna@redhat.com
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCHv3 1/4] qapi: add explicit null to string input and output visitors
Date: Tue, 2 May 2017 13:48:15 +0200 [thread overview]
Message-ID: <20170502134815.3f0e94ff@bahia> (raw)
In-Reply-To: <20170427072843.8089-2-david@gibson.dropbear.id.au>
[-- Attachment #1: Type: text/plain, Size: 3210 bytes --]
On Thu, 27 Apr 2017 17:28:40 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:
> From: Greg Kurz <groug@kaod.org>
>
> This may be used for deprecated object properties that are kept for
> backwards compatibility.
>
> Signed-off-by: Greg Kurz <groug@kaod.org>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> qapi/string-input-visitor.c | 11 +++++++++++
> qapi/string-output-visitor.c | 14 ++++++++++++++
> 2 files changed, 25 insertions(+)
>
> diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c
> index c089491..63ae115 100644
> --- a/qapi/string-input-visitor.c
> +++ b/qapi/string-input-visitor.c
> @@ -326,6 +326,16 @@ static void parse_type_number(Visitor *v, const char *name, double *obj,
> *obj = val;
> }
>
> +static void parse_type_null(Visitor *v, const char *name, Error **errp)
> +{
> + StringInputVisitor *siv = to_siv(v);
> +
> + if (!siv->string || siv->string[0]) {
> + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
> + "null");
I had boldly copied the error_setg() line from qobject_input_type_null(), but
I guess the 3rd argument ("null") isn't really appropriate to describe the
expected input in this case.
What about something like below ?
+ error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
+ "empty string");
> + }
> +}
> +
> static void string_input_free(Visitor *v)
> {
> StringInputVisitor *siv = to_siv(v);
> @@ -349,6 +359,7 @@ Visitor *string_input_visitor_new(const char *str)
> v->visitor.type_bool = parse_type_bool;
> v->visitor.type_str = parse_type_str;
> v->visitor.type_number = parse_type_number;
> + v->visitor.type_null = parse_type_null;
> v->visitor.start_list = start_list;
> v->visitor.next_list = next_list;
> v->visitor.check_list = check_list;
> diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
> index 94ac821..5ec5352 100644
> --- a/qapi/string-output-visitor.c
> +++ b/qapi/string-output-visitor.c
> @@ -266,6 +266,19 @@ static void print_type_number(Visitor *v, const char *name, double *obj,
> string_output_set(sov, g_strdup_printf("%f", *obj));
> }
>
> +static void print_type_null(Visitor *v, const char *name, Error **errp)
> +{
> + StringOutputVisitor *sov = to_sov(v);
> + char *out;
> +
> + if (sov->human) {
> + out = g_strdup("<null>");
> + } else {
> + out = g_strdup("");
> + }
> + string_output_set(sov, out);
> +}
> +
> static void
> start_list(Visitor *v, const char *name, GenericList **list, size_t size,
> Error **errp)
> @@ -351,6 +364,7 @@ Visitor *string_output_visitor_new(bool human, char **result)
> v->visitor.type_bool = print_type_bool;
> v->visitor.type_str = print_type_str;
> v->visitor.type_number = print_type_number;
> + v->visitor.type_null = print_type_null;
> v->visitor.start_list = start_list;
> v->visitor.next_list = next_list;
> v->visitor.end_list = end_list;
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
next prev parent reply other threads:[~2017-05-02 11:48 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 7:28 [Qemu-devel] [PATCHv3 0/4] Clean up compatibility mode handling David Gibson
2017-04-27 7:28 ` [Qemu-devel] [PATCHv3 1/4] qapi: add explicit null to string input and output visitors David Gibson
2017-05-02 11:48 ` Greg Kurz [this message]
2017-04-27 7:28 ` [Qemu-devel] [PATCHv3 2/4] pseries: Move CPU compatibility property to machine David Gibson
2017-04-27 17:23 ` Michael Roth
2017-05-01 2:33 ` David Gibson
2017-05-02 11:23 ` Greg Kurz
2017-05-02 14:24 ` Greg Kurz
2017-05-26 1:24 ` David Gibson
2017-05-04 10:06 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-05-04 17:09 ` [Qemu-devel] " Andrea Bolognani
2017-05-04 18:50 ` Greg Kurz
2017-05-12 7:08 ` David Gibson
2017-05-26 2:10 ` David Gibson
2017-04-27 7:28 ` [Qemu-devel] [PATCHv3 3/4] pseries: Reset CPU compatibility mode David Gibson
2017-04-27 18:08 ` Michael Roth
2017-04-27 7:28 ` [Qemu-devel] [PATCHv3 4/4] ppc: Rework CPU compatibility testing across migration David Gibson
2017-04-27 19:51 ` Michael Roth
2017-05-01 6:48 ` David Gibson
2017-05-26 3:40 ` David Gibson
2017-05-04 10:07 ` Greg Kurz
2017-05-26 4:16 ` David Gibson
2017-05-29 10:51 ` Greg Kurz
2017-04-27 8:04 ` [Qemu-devel] [PATCHv3 0/4] Clean up compatibility mode handling no-reply
2017-04-28 9:29 ` Greg Kurz
2017-05-03 18:03 ` Greg Kurz
2017-05-04 14:32 ` Andrea Bolognani
2017-05-04 19:22 ` [Qemu-devel] [Qemu-ppc] " Greg Kurz
2017-05-12 7:33 ` David Gibson
2017-05-12 8:33 ` Andrea Bolognani
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=20170502134815.3f0e94ff@bahia \
--to=groug@kaod.org \
--cc=abologna@redhat.com \
--cc=aik@ozlabs.ru \
--cc=armbru@redhat.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=mdroth@linux.vnet.ibm.com \
--cc=nikunj@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.