qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: peter.maydell@linaro.org
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 02/10] QJSON: Use OBJECT_CHECK
Date: Fri,  8 May 2015 09:34:03 -0400	[thread overview]
Message-ID: <1431092051-31046-3-git-send-email-lcapitulino@redhat.com> (raw)
In-Reply-To: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com>

From: Eduardo Habkost <ehabkost@redhat.com>

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>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 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));
 }
 
-- 
1.9.3

  parent reply	other threads:[~2015-05-08 13:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 13:34 [Qemu-devel] [PULL 00/10] QMP queue Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 01/10] monitor: add memory search commands s, sp Luiz Capitulino
2015-05-08 13:34 ` Luiz Capitulino [this message]
2015-05-08 13:34 ` [Qemu-devel] [PULL 03/10] qobject: Clean up around qtype_code Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 04/10] qobject: Add a special null QObject Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 05/10] json-parser: Accept 'null' in QMP Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 06/10] MAINTAINERS: New maintainer for QMP and QAPI Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 07/10] scripts: qmp-shell: refactor helpers Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 08/10] scripts: qmp-shell: Expand support for QMP expressions Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 09/10] scripts: qmp-shell: add transaction subshell Luiz Capitulino
2015-05-08 13:34 ` [Qemu-devel] [PULL 10/10] scripts: qmp-shell: Add verbose flag Luiz Capitulino
2015-05-11 12:53 ` [Qemu-devel] [PULL 00/10] QMP queue Peter Maydell
2015-05-11 13:17   ` Luiz Capitulino
2015-05-12  9:40     ` Peter Maydell

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=1431092051-31046-3-git-send-email-lcapitulino@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@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 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).