From nobody Mon Feb 9 00:56:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1606762582; cv=none; d=zohomail.com; s=zohoarc; b=Q0cwO17/Hu7Ahng5J9hwXTlg1hNCxP74PBjBKbs3JQ9BbbFfTWeolbXxuQKn01nC8Bo0H0FZFqy4hdQlDGYWq6Kf565+Le6X4hfYF7q9vnYBLSPehNt6/r4HV0fPwcNSh4tX3jes5wXflCAxwQRXaYsmHtVXgAz+DT4p+zIhyDY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606762582; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eKakUmFHDghRmf6gDEKfEMfGfUsZ+qJNfjinZa3O7GA=; b=YI4Mb0BxnQg5RlWHR2ILvCM/gTB5+ibA/Afl/9ldqIfFxqu8q2AHfGPPmDP7ZjO6hx7H6x+8+bByGbzlXYG0fALiBXnBFeQTcpblcR8WoF2WMBaPPKCuSW3B5XaZfEIdpzy4wLIbOO3hqb5m9ygBxsSMdRhkX2cEUeetAa4iNik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1606762582446509.3149619360819; Mon, 30 Nov 2020 10:56:22 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-487-1Q62IxwlOQGun611qxTnwA-1; Mon, 30 Nov 2020 13:56:18 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCCF1817B85; Mon, 30 Nov 2020 18:56:10 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99F8C5C1A3; Mon, 30 Nov 2020 18:56:10 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6491D50039; Mon, 30 Nov 2020 18:56:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AUItsQn014258 for ; Mon, 30 Nov 2020 13:55:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 09B0D60C67; Mon, 30 Nov 2020 18:55:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA75860C6A for ; Mon, 30 Nov 2020 18:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606762581; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eKakUmFHDghRmf6gDEKfEMfGfUsZ+qJNfjinZa3O7GA=; b=aM1BYmlAbW1w+0UcjRU9gubiwZDGHaHMbsJTsTTQbGGm46bMbwXL4gaBVzzPECCeUl9QhN ZR3JlJEYnKEcZbI4jEmHFnSjvXWl+OLldEzbmxo5aHvkemVE/30egLO1Qnpc/7hAJdtpx/ pfVBGci2SRgqD4VpDUfcxL/30nRCPUY= X-MC-Unique: 1Q62IxwlOQGun611qxTnwA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/24] util: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey Date: Mon, 30 Nov 2020 19:55:22 +0100 Message-Id: <860e1193dd6f5acbceb1e911ea77100541d3b6fb.1606762033.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" virJSONValueObjectRemoveKey can be used as direct replacement. Fix the one caller and remove the duplicate function. Signed-off-by: Peter Krempa --- src/util/virjson.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index 3fa9a9ca24..9b01e28eb5 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -883,30 +883,6 @@ virJSONValueObjectGet(virJSONValuePtr object, } -static virJSONValuePtr -virJSONValueObjectSteal(virJSONValuePtr object, - const char *key) -{ - size_t i; - virJSONValuePtr obj =3D NULL; - - if (object->type !=3D VIR_JSON_TYPE_OBJECT) - return NULL; - - for (i =3D 0; i < object->data.object.npairs; i++) { - if (STREQ(object->data.object.pairs[i].key, key)) { - obj =3D g_steal_pointer(&object->data.object.pairs[i].value); - VIR_FREE(object->data.object.pairs[i].key); - VIR_DELETE_ELEMENT(object->data.object.pairs, i, - object->data.object.npairs); - break; - } - } - - return obj; -} - - /* Return the value associated with KEY within OBJECT, but return NULL * if the key is missing or if value is not the correct TYPE. */ virJSONValuePtr @@ -929,7 +905,10 @@ virJSONValueObjectStealByType(virJSONValuePtr object, const char *key, virJSONType type) { - virJSONValuePtr value =3D virJSONValueObjectSteal(object, key); + virJSONValuePtr value; + + if (virJSONValueObjectRemoveKey(object, key, &value) <=3D 0) + return NULL; if (value && value->type =3D=3D type) return value; --=20 2.28.0