From patchwork Fri Dec 13 17:10:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 301103 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 639ED2C0085 for ; Sat, 14 Dec 2013 04:11:40 +1100 (EST) Received: from localhost ([::1]:43778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrWH3-0002kH-Lb for incoming@patchwork.ozlabs.org; Fri, 13 Dec 2013 12:11:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrWFm-0001qR-CM for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:10:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrWFf-0007uI-VY for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:10:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:29276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrWFf-0007u6-Ks for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:10:11 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDHAA4t016103 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 12:10:11 -0500 Received: from localhost (ovpn-116-117.ams2.redhat.com [10.36.116.117]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBDHA4Pb015766 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Fri, 13 Dec 2013 12:10:07 -0500 From: Max Reitz To: qemu-devel@nongnu.org Date: Fri, 13 Dec 2013 18:10:16 +0100 Message-Id: <1386954633-28905-6-git-send-email-mreitz@redhat.com> In-Reply-To: <1386954633-28905-1-git-send-email-mreitz@redhat.com> References: <1386954633-28905-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v5 05/22] qdict: Remove delete from qdict_flatten_qdict() 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 delete is always set to true, therefore it can be removed. Signed-off-by: Max Reitz --- qobject/qdict.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/qobject/qdict.c b/qobject/qdict.c index 1d0e66c..ec42b1c 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -520,18 +520,15 @@ static void qdict_flatten_qlist(QList *qlist, QDict *target, const char *prefix) static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix) { QObject *value; - const QDictEntry *entry, *next; + const QDictEntry *entry; char *new_key; - bool delete; entry = qdict_first(qdict); while (entry != NULL) { - next = qdict_next(qdict, entry); value = qdict_entry_value(entry); new_key = NULL; - delete = false; if (prefix) { new_key = g_strdup_printf("%s.%s", prefix, entry->key); @@ -542,29 +539,21 @@ static void qdict_flatten_qdict(QDict *qdict, QDict *target, const char *prefix) * itself disappears. */ qdict_flatten_qdict(qobject_to_qdict(value), target, new_key ? new_key : entry->key); - delete = true; } else if (qobject_type(value) == QTYPE_QLIST) { qdict_flatten_qlist(qobject_to_qlist(value), target, new_key ? new_key : entry->key); - delete = true; } else if (prefix) { /* All other objects are moved to the target unchanged. */ qobject_incref(value); qdict_put_obj(target, new_key, value); - delete = true; } g_free(new_key); - if (delete) { - qdict_del(qdict, entry->key); - - /* Restart loop after modifying the iterated QDict */ - entry = qdict_first(qdict); - continue; - } + qdict_del(qdict, entry->key); - entry = next; + /* Restart loop after modifying the iterated QDict */ + entry = qdict_first(qdict); } }