qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Juan Quintela" <quintela@redhat.com>,
	qemu-devel@nongnu.org, "Andreas Färber" <afaerber@suse.de>,
	agraf@suse.de
Subject: Re: [Qemu-devel] [PATCH] QJSON: Use OBJECT_CHECK
Date: Fri, 1 May 2015 13:16:02 -0400	[thread overview]
Message-ID: <20150501131602.1d1456e9@redhat.com> (raw)
In-Reply-To: <1429975686-19494-1-git-send-email-ehabkost@redhat.com>

On Sat, 25 Apr 2015 12:28:06 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> The QJSON code used casts to (QJSON*) directly, instead of OBJECT_CHECK.
> There were even some functions using object_dynamic_cast() calls
> followed by assert(), which is exactly what OBJECT_CHECK does (by
> calling object_dynamic_cast_assert()).
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>

Applied to the qmp branch, thanks.

> ---
>  qjson.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/qjson.c b/qjson.c
> index 0cda269..e478802 100644
> --- a/qjson.c
> +++ b/qjson.c
> @@ -24,6 +24,8 @@ struct QJSON {
>      bool omit_comma;
>  };
>  
> +#define QJSON(obj) OBJECT_CHECK(QJSON, (obj), TYPE_QJSON)
> +
>  static void json_emit_element(QJSON *json, const char *name)
>  {
>      /* Check whether we need to print a , before an element */
> @@ -87,7 +89,7 @@ const char *qjson_get_str(QJSON *json)
>  
>  QJSON *qjson_new(void)
>  {
> -    QJSON *json = (QJSON *)object_new(TYPE_QJSON);
> +    QJSON *json = QJSON(object_new(TYPE_QJSON));
>      return json;
>  }
>  
> @@ -98,8 +100,7 @@ void qjson_finish(QJSON *json)
>  
>  static void qjson_initfn(Object *obj)
>  {
> -    QJSON *json = (QJSON *)object_dynamic_cast(obj, TYPE_QJSON);
> -    assert(json);
> +    QJSON *json = QJSON(obj);
>  
>      json->str = qstring_from_str("{ ");
>      json->omit_comma = true;
> @@ -107,9 +108,8 @@ static void qjson_initfn(Object *obj)
>  
>  static void qjson_finalizefn(Object *obj)
>  {
> -    QJSON *json = (QJSON *)object_dynamic_cast(obj, TYPE_QJSON);
> +    QJSON *json = QJSON(obj);
>  
> -    assert(json);
>      qobject_decref(QOBJECT(json->str));
>  }
>  

      parent reply	other threads:[~2015-05-01 17:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-25 15:28 [Qemu-devel] [PATCH] QJSON: Use OBJECT_CHECK Eduardo Habkost
2015-04-25 17:05 ` Andreas Färber
2015-04-27 17:23   ` Eduardo Habkost
2015-04-29 12:38     ` Luiz Capitulino
2015-04-29 12:46       ` Andreas Färber
2015-04-29 12:54         ` Luiz Capitulino
2015-04-29 12:55       ` Eduardo Habkost
2015-04-29 13:00         ` Luiz Capitulino
2015-05-01 16:19         ` Michael Roth
2015-05-01 16:23           ` Michael Roth
2015-05-02 14:44             ` Alexander Graf
2015-04-29 19:18     ` Paolo Bonzini
2015-05-01 12:04       ` Eduardo Habkost
2015-05-05 12:43     ` Juan Quintela
2015-05-05 12:53       ` Luiz Capitulino
2015-05-05 13:32         ` Juan Quintela
2015-05-01 17:16 ` Luiz Capitulino [this message]

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=20150501131602.1d1456e9@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=ehabkost@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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).