From nobody Mon Feb 9 04:42:18 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@gnu.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@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506656599036136.17889550433324; Thu, 28 Sep 2017 20:43:19 -0700 (PDT) Received: from localhost ([::1]:33546 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxmCs-00008r-85 for importer@patchew.org; Thu, 28 Sep 2017 23:43:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35823) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxm8v-0005G8-3D for qemu-devel@nongnu.org; Thu, 28 Sep 2017 23:39:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxm8p-0006Gm-K4 for qemu-devel@nongnu.org; Thu, 28 Sep 2017 23:39:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxm8p-0006GJ-DC for qemu-devel@nongnu.org; Thu, 28 Sep 2017 23:39:07 -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 6E99285540; Fri, 29 Sep 2017 03:39:06 +0000 (UTC) Received: from pxdev.xzpeter.org.com (ovpn-12-70.pek2.redhat.com [10.72.12.70]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4476618954; Fri, 29 Sep 2017 03:39:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6E99285540 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=peterx@redhat.com From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 11:38:25 +0800 Message-Id: <20170929033844.26935-4-peterx@redhat.com> In-Reply-To: <20170929033844.26935-1-peterx@redhat.com> References: <20170929033844.26935-1-peterx@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.28]); Fri, 29 Sep 2017 03:39:06 +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] [RFC v2 03/22] qobject: introduce qobject_get_try_str() X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Fam Zheng , Juan Quintela , Markus Armbruster , peterx@redhat.com, mdroth@linux.vnet.ibm.com, Stefan Hajnoczi , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.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" A quick way to fetch string from qobject when it's a QString. Signed-off-by: Peter Xu --- include/qapi/qmp/qstring.h | 1 + qobject/qstring.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h index 34278bd639..12ae4e1c29 100644 --- a/include/qapi/qmp/qstring.h +++ b/include/qapi/qmp/qstring.h @@ -28,6 +28,7 @@ QString *qstring_from_substr(const char *str, int start, = int end); size_t qstring_get_length(const QString *qstring); const char *qstring_get_str(const QString *qstring); const char *qstring_get_try_str(const QString *qstring); +const char *qobject_get_try_str(const QObject *qstring); void qstring_append_int(QString *qstring, int64_t value); void qstring_append(QString *qstring, const char *str); void qstring_append_chr(QString *qstring, int c); diff --git a/qobject/qstring.c b/qobject/qstring.c index 9df04e3c7b..bbe689a9e3 100644 --- a/qobject/qstring.c +++ b/qobject/qstring.c @@ -139,6 +139,17 @@ const char *qstring_get_try_str(const QString *qstring) } =20 /** + * qobject_get_try_str(): Return a pointer of the backstore string + * + * NOTE: the string will only be returned if the object is valid, and + * its type is QString, otherwise NULL is returned. + */ +const char *qobject_get_try_str(const QObject *qstring) +{ + return qstring_get_try_str(qobject_to_qstring(qstring)); +} + +/** * qstring_destroy_obj(): Free all memory allocated by a QString * object */ --=20 2.13.5