From nobody Mon Feb 9 08:55:27 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 1510352164206673.7357217257044; Fri, 10 Nov 2017 14:16:04 -0800 (PST) Received: from localhost ([::1]:43667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDHab-0006H6-Al for importer@patchew.org; Fri, 10 Nov 2017 17:15:53 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDHYS-0004ii-D4 for qemu-devel@nongnu.org; Fri, 10 Nov 2017 17:13:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDHYR-0005YN-JV for qemu-devel@nongnu.org; Fri, 10 Nov 2017 17:13:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39832) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eDHYN-0005WX-E5; Fri, 10 Nov 2017 17:13:35 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FFB3820ED; Fri, 10 Nov 2017 22:13:34 +0000 (UTC) Received: from localhost (ovpn-204-126.brq.redhat.com [10.40.204.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 36AF36F45E; Fri, 10 Nov 2017 22:13:34 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 10 Nov 2017 23:13:27 +0100 Message-Id: <20171110221329.24176-2-mreitz@redhat.com> In-Reply-To: <20171110221329.24176-1-mreitz@redhat.com> References: <20171110221329.24176-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 10 Nov 2017 22:13:34 +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] [PATCH for-2.12 1/3] qapi: Add qdict_is_null() 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: , Cc: Kevin Wolf , Markus Armbruster , qemu-devel@nongnu.org, Max Reitz 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: Max Reitz Reviewed-by: Alberto Garcia Reviewed-by: Eric Blake --- include/qapi/qmp/qdict.h | 1 + qobject/qdict.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index fc218e7be6..c65ebfc748 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -76,6 +76,7 @@ int64_t qdict_get_try_int(const QDict *qdict, const char = *key, int64_t def_value); bool qdict_get_try_bool(const QDict *qdict, const char *key, bool def_valu= e); const char *qdict_get_try_str(const QDict *qdict, const char *key); +bool qdict_is_qnull(const QDict *qdict, const char *key); =20 void qdict_copy_default(QDict *dst, QDict *src, const char *key); void qdict_set_default_str(QDict *dst, const char *key, const char *val); diff --git a/qobject/qdict.c b/qobject/qdict.c index e8f15f1132..a032ea629a 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -294,6 +294,16 @@ const char *qdict_get_try_str(const QDict *qdict, cons= t char *key) } =20 /** + * qdict_is_qnull(): Return true if the value for 'key' is QNull + */ +bool qdict_is_qnull(const QDict *qdict, const char *key) +{ + QObject *value =3D qdict_get(qdict, key); + + return value && value->type =3D=3D QTYPE_QNULL; +} + +/** * qdict_iter(): Iterate over all the dictionary's stored values. * * This function allows the user to provide an iterator, which will be --=20 2.13.6