From nobody Tue Nov 4 15:13:13 2025 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; dkim=fail; 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 1530272643158429.49089920288645; Fri, 29 Jun 2018 04:44:03 -0700 (PDT) Received: from localhost ([::1]:41373 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYroo-0006Ii-D6 for importer@patchew.org; Fri, 29 Jun 2018 07:44:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYrjC-0001rp-67 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYriz-0005HR-HF for qemu-devel@nongnu.org; Fri, 29 Jun 2018 07:38:14 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:41379) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYriz-0004Tf-3K; Fri, 29 Jun 2018 07:38:01 -0400 Received: from 88-114-101-78.elisa-laajakaista.fi ([88.114.101.78] helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1fYriP-0006P0-Bo; Fri, 29 Jun 2018 13:37:25 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1fYriA-0008Ka-NE; Fri, 29 Jun 2018 14:37:10 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=n2AOkzT1cgPSDRyqA/71NhbWcv65omn459N+4vTZMoA=; b=HyYqqFvbTvAVoCuyo3C/6qK7h5qjPXYHZSGFZ4tGmiECgc87mNOiylIpFlq9khGgFpY3aACjwV+4/sxuf+WbMauVCC01E7jjaU0NGF0krPWvAM1L67MTmtovc7RxO0lwf3DzI6/nbeppnQsXEmjiOmKO5+Dj12mZSL+BuYUVCbeH4E40v+umjfyt/x9+V3ozKv+y+L6FJRpAE9qYkzz1pkNdHpwTvuRR/0v52Fg8+RM5Rhz2oTN276evcAxuxfHK5ZkQ8LZWdP8AFgW+7nJd2+Xmc8HzeyHYX1WMcDBPbJpX0Jn7qFRukjCHAwxPul03PwcGs5HRifFZwZHPNAMSZA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 14:36:59 +0300 Message-Id: <6d4bbe2a722855e10655f9f5ee1dbf4e94f62e59.1530270904.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH 1/5] qdict: Make qdict_extract_subqdict() accept dst = 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 , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This function extracts all options from a QDict starting with a certain prefix and puts them in a new QDict. We'll have a couple of cases where we simply want to discard those options instead of copying them, and that's what this patch does. Signed-off-by: Alberto Garcia --- qobject/block-qdict.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c index 36129e7379..ef443cb8d5 100644 --- a/qobject/block-qdict.c +++ b/qobject/block-qdict.c @@ -158,20 +158,25 @@ void qdict_flatten(QDict *qdict) qdict_flatten_qdict(qdict, qdict, NULL); } =20 -/* extract all the src QDict entries starting by start into dst */ +/* extract all the src QDict entries starting by start into dst. + * If dst is NULL then the entries are simply removed from src. */ void qdict_extract_subqdict(QDict *src, QDict **dst, const char *start) =20 { const QDictEntry *entry, *next; const char *p; =20 - *dst =3D qdict_new(); + if (dst) { + *dst =3D qdict_new(); + } entry =3D qdict_first(src); =20 while (entry !=3D NULL) { next =3D qdict_next(src, entry); if (strstart(entry->key, start, &p)) { - qdict_put_obj(*dst, p, qobject_ref(entry->value)); + if (dst) { + qdict_put_obj(*dst, p, qobject_ref(entry->value)); + } qdict_del(src, entry->key); } entry =3D next; --=20 2.11.0