From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YoEr7-00037y-5k for qemu-devel@nongnu.org; Fri, 01 May 2015 13:36:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YoEqz-0004zy-UY for qemu-devel@nongnu.org; Fri, 01 May 2015 13:36:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YoEqz-0004zp-Pp for qemu-devel@nongnu.org; Fri, 01 May 2015 13:35:57 -0400 Date: Fri, 1 May 2015 13:16:02 -0400 From: Luiz Capitulino Message-ID: <20150501131602.1d1456e9@redhat.com> In-Reply-To: <1429975686-19494-1-git-send-email-ehabkost@redhat.com> References: <1429975686-19494-1-git-send-email-ehabkost@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] QJSON: Use OBJECT_CHECK List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Juan Quintela , qemu-devel@nongnu.org, Andreas =?UTF-8?B?RsOkcmJlcg==?= , agraf@suse.de On Sat, 25 Apr 2015 12:28:06 -0300 Eduardo Habkost 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 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)); > } >