From patchwork Wed Nov 18 20:39:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 546195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1E91414140E for ; Thu, 19 Nov 2015 07:42:03 +1100 (AEDT) Received: from localhost ([::1]:38267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz9YG-0005fq-Eh for incoming@patchwork.ozlabs.org; Wed, 18 Nov 2015 15:42:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz9W4-0001Za-GL for qemu-devel@nongnu.org; Wed, 18 Nov 2015 15:39:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zz9W2-0005Sc-27 for qemu-devel@nongnu.org; Wed, 18 Nov 2015 15:39:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:49493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz9W1-0005SJ-Rk for qemu-devel@nongnu.org; Wed, 18 Nov 2015 15:39:41 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B6DBFAD07; Wed, 18 Nov 2015 20:39:17 +0000 (UTC) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Wed, 18 Nov 2015 21:39:31 +0100 Message-Id: <1447879178-5440-4-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1447879178-5440-1-git-send-email-afaerber@suse.de> References: <1447879178-5440-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , Markus Armbruster Subject: [Qemu-devel] [PULL 03/10] qmp: Convert QMP code to use object property iterators 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: "Daniel P. Berrange" Stop directly accessing the Object::properties field data structure and instead use the formal object property iterator APIs. This insulates the code from future data structure changes in the Object struct. Signed-off-by: Daniel P. Berrange Tested-by: Pavel Fedin Signed-off-by: Andreas Färber --- qmp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qmp.c b/qmp.c index ddc63ea..0a1fa19 100644 --- a/qmp.c +++ b/qmp.c @@ -210,6 +210,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) bool ambiguous = false; ObjectPropertyInfoList *props = NULL; ObjectProperty *prop; + ObjectPropertyIterator *iter; obj = object_resolve_path(path, &ambiguous); if (obj == NULL) { @@ -222,7 +223,8 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) return NULL; } - QTAILQ_FOREACH(prop, &obj->properties, node) { + iter = object_property_iter_init(obj); + while ((prop = object_property_iter_next(iter))) { ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry)); entry->value = g_malloc0(sizeof(ObjectPropertyInfo)); @@ -232,6 +234,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) entry->value->name = g_strdup(prop->name); entry->value->type = g_strdup(prop->type); } + object_property_iter_free(iter); return props; } @@ -503,6 +506,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, ObjectClass *klass; Object *obj; ObjectProperty *prop; + ObjectPropertyIterator *iter; DevicePropertyInfoList *prop_list = NULL; klass = object_class_by_name(typename); @@ -531,7 +535,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, obj = object_new(typename); - QTAILQ_FOREACH(prop, &obj->properties, node) { + iter = object_property_iter_init(obj); + while ((prop = object_property_iter_next(iter))) { DevicePropertyInfo *info; DevicePropertyInfoList *entry; @@ -562,6 +567,7 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename, entry->next = prop_list; prop_list = entry; } + object_property_iter_free(iter); object_unref(obj);