From nobody Mon Feb 9 02:13:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500897533363997.5728006275147; Mon, 24 Jul 2017 04:58:53 -0700 (PDT) Received: from localhost ([::1]:54234 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZc0g-0002GK-Vu for importer@patchew.org; Mon, 24 Jul 2017 07:58:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZbyy-000157-If for qemu-devel@nongnu.org; Mon, 24 Jul 2017 07:57:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZbyw-0006rm-LI for qemu-devel@nongnu.org; Mon, 24 Jul 2017 07:57:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dZbyw-0006rD-Bm for qemu-devel@nongnu.org; Mon, 24 Jul 2017 07:57:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 47A22C0B772F for ; Mon, 24 Jul 2017 11:57:01 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D15C170BB0 for ; Mon, 24 Jul 2017 11:57:00 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 42B61113864B; Mon, 24 Jul 2017 13:56:59 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 47A22C0B772F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=armbru@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 47A22C0B772F From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:56:50 +0200 Message-Id: <1500897419-15539-2-git-send-email-armbru@redhat.com> In-Reply-To: <1500897419-15539-1-git-send-email-armbru@redhat.com> References: <1500897419-15539-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 24 Jul 2017 11:57:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL v2 01/10] qapi: Separate type QNull from QObject X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Daniel P. Berrange --- include/qapi/qmp/qobject.h | 10 +++++++--- qapi/qobject-output-visitor.c | 2 +- qobject/json-parser.c | 2 +- qobject/qnull.c | 8 +++++--- target/i386/cpu.c | 4 ++-- tests/check-qjson.c | 6 +++--- tests/check-qnull.c | 18 +++++++++--------- 7 files changed, 28 insertions(+), 22 deletions(-) diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index b8ddbca..3543b55 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -93,11 +93,15 @@ static inline QType qobject_type(const QObject *obj) return obj->type; } =20 -extern QObject qnull_; +typedef struct QNull { + QObject base; +} QNull; =20 -static inline QObject *qnull(void) +extern QNull qnull_; + +static inline QNull *qnull(void) { - qobject_incref(&qnull_); + QINCREF(&qnull_); return &qnull_; } =20 diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 70be84c..398dcb5 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -190,7 +190,7 @@ static void qobject_output_type_any(Visitor *v, const c= har *name, static void qobject_output_type_null(Visitor *v, const char *name, Error *= *errp) { QObjectOutputVisitor *qov =3D to_qov(v); - qobject_output_add_obj(qov, name, qnull()); + qobject_output_add(qov, name, qnull()); } =20 /* Finish building, and return the root object. diff --git a/qobject/json-parser.c b/qobject/json-parser.c index 7a417f2..724ca24 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -445,7 +445,7 @@ static QObject *parse_keyword(JSONParserContext *ctxt) } else if (!strcmp(token->str, "false")) { return QOBJECT(qbool_from_bool(false)); } else if (!strcmp(token->str, "null")) { - return qnull(); + return QOBJECT(qnull()); } parse_error(ctxt, token, "invalid keyword '%s'", token->str); return NULL; diff --git a/qobject/qnull.c b/qobject/qnull.c index c124d05..69a21d1 100644 --- a/qobject/qnull.c +++ b/qobject/qnull.c @@ -14,7 +14,9 @@ #include "qemu-common.h" #include "qapi/qmp/qobject.h" =20 -QObject qnull_ =3D { - .type =3D QTYPE_QNULL, - .refcnt =3D 1, +QNull qnull_ =3D { + .base =3D { + .type =3D QTYPE_QNULL, + .refcnt =3D 1, + }, }; diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0bbda76..89f5fb7 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -2442,7 +2442,7 @@ static QDict *x86_cpu_static_props(void) =20 d =3D qdict_new(); for (i =3D 0; props[i]; i++) { - qdict_put_obj(d, props[i], qnull()); + qdict_put(d, props[i], qnull()); } =20 for (w =3D 0; w < FEATURE_WORDS; w++) { @@ -2452,7 +2452,7 @@ static QDict *x86_cpu_static_props(void) if (!fi->feat_names[bit]) { continue; } - qdict_put_obj(d, fi->feat_names[bit], qnull()); + qdict_put(d, fi->feat_names[bit], qnull()); } } =20 diff --git a/tests/check-qjson.c b/tests/check-qjson.c index 53f2275..a3a97b0 100644 --- a/tests/check-qjson.c +++ b/tests/check-qjson.c @@ -1012,7 +1012,7 @@ static void keyword_literal(void) { QObject *obj; QBool *qbool; - QObject *null; + QNull *null; QString *str; =20 obj =3D qobject_from_json("true", &error_abort); @@ -1053,10 +1053,10 @@ static void keyword_literal(void) g_assert(qobject_type(obj) =3D=3D QTYPE_QNULL); =20 null =3D qnull(); - g_assert(null =3D=3D obj); + g_assert(QOBJECT(null) =3D=3D obj); =20 qobject_decref(obj); - qobject_decref(null); + QDECREF(null); } =20 typedef struct LiteralQDictEntry LiteralQDictEntry; diff --git a/tests/check-qnull.c b/tests/check-qnull.c index 8dd1c96..1ab7c98 100644 --- a/tests/check-qnull.c +++ b/tests/check-qnull.c @@ -24,14 +24,14 @@ static void qnull_ref_test(void) { QObject *obj; =20 - g_assert(qnull_.refcnt =3D=3D 1); - obj =3D qnull(); + g_assert(qnull_.base.refcnt =3D=3D 1); + obj =3D QOBJECT(qnull()); g_assert(obj); - g_assert(obj =3D=3D &qnull_); - g_assert(qnull_.refcnt =3D=3D 2); + g_assert(obj =3D=3D QOBJECT(&qnull_)); + g_assert(qnull_.base.refcnt =3D=3D 2); g_assert(qobject_type(obj) =3D=3D QTYPE_QNULL); qobject_decref(obj); - g_assert(qnull_.refcnt =3D=3D 1); + g_assert(qnull_.base.refcnt =3D=3D 1); } =20 static void qnull_visit_test(void) @@ -45,8 +45,8 @@ static void qnull_visit_test(void) * depend on layering violations to check qnull_ refcnt. */ =20 - g_assert(qnull_.refcnt =3D=3D 1); - obj =3D qnull(); + g_assert(qnull_.base.refcnt =3D=3D 1); + obj =3D QOBJECT(qnull()); v =3D qobject_input_visitor_new(obj); qobject_decref(obj); visit_type_null(v, NULL, &error_abort); @@ -55,11 +55,11 @@ static void qnull_visit_test(void) v =3D qobject_output_visitor_new(&obj); visit_type_null(v, NULL, &error_abort); visit_complete(v, &obj); - g_assert(obj =3D=3D &qnull_); + g_assert(obj =3D=3D QOBJECT(&qnull_)); qobject_decref(obj); visit_free(v); =20 - g_assert(qnull_.refcnt =3D=3D 1); + g_assert(qnull_.base.refcnt =3D=3D 1); } =20 int main(int argc, char **argv) --=20 2.7.5