From patchwork Fri May 8 13:34:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 470044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0F863140291 for ; Fri, 8 May 2015 23:35:02 +1000 (AEST) Received: from localhost ([::1]:55834 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiQd-0001uQ-W5 for incoming@patchwork.ozlabs.org; Fri, 08 May 2015 09:35:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiQ0-0000mM-6Q for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqiPz-0002Vk-7O for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47269) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqiPz-0002VJ-0r for qemu-devel@nongnu.org; Fri, 08 May 2015 09:34:19 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t48DYFPk024554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 8 May 2015 09:34:17 -0400 Received: from localhost (ovpn-113-30.phx2.redhat.com [10.3.113.30]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t48DYFlW023300; Fri, 8 May 2015 09:34:15 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 8 May 2015 09:34:03 -0400 Message-Id: <1431092051-31046-3-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com> References: <1431092051-31046-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 02/10] QJSON: Use OBJECT_CHECK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Eduardo Habkost 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 Signed-off-by: Luiz Capitulino --- 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)); }