From nobody Sun Feb 8 22:50:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1609941865; cv=none; d=zohomail.com; s=zohoarc; b=Ulkz0W4T5X/47tP5zUom/AjdReK/2ZHyjYkbF3b/b3ci1J7sStmgRnQwxNQt9x2zDpMZAv20xhc6yeRDcuHjywE2Huv6OR9GUgBhe2d3VVnqCKuiFTuiZp24vf6XvE2qkxigYSPdfQ+q6ymxZgXHViOsInXDw7yL2WsXPs8t03k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609941865; 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=OTVULDqW36+UgYIcOnw5RUkMyK3+5xFhRw/ndkN9VyY=; b=VVPwl5EwC/l5p9qiESQSRzwH8rbpZb+ESaKVc9J7YwcVrZMBH8F1I5YsTHhklnRFHHt0Z2ekgxEVE66DlpUhY86k4J0h7D1730HFz/a5jczV5w3UIwuDRC3TlLj3myY1k7IH0RL47raZ6KFxclmM8Uq1r0sEjeTOHI3Q9iFADDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1609941865799177.58082925115104; Wed, 6 Jan 2021 06:04:25 -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-10-DGDt-pqbNsG28_7TbwuRlg-1; Wed, 06 Jan 2021 09:04:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 159A0180E46C; Wed, 6 Jan 2021 14:04:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E0E6C1002393; Wed, 6 Jan 2021 14:04:12 +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 A71261809CA5; Wed, 6 Jan 2021 14:04:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 106E3xLd031420 for ; Wed, 6 Jan 2021 09:03:59 -0500 Received: by smtp.corp.redhat.com (Postfix) id 99AE26267A; Wed, 6 Jan 2021 14:03:59 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F15B462680 for ; Wed, 6 Jan 2021 14:03:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609941864; 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=OTVULDqW36+UgYIcOnw5RUkMyK3+5xFhRw/ndkN9VyY=; b=aI9dq4vywxo6bIkpK+a/4Q0wkUZYBuVPkkopE2tm2amUGVQZqbxUQ3GBs4d2T+C6o2KoO8 ojh1/uSWUnoK3Nv9Wn0OQgZjFTnA2lCASAzQGbO2XoCIJ9PL9dSiGBPmN/z2N2T//RQwQ7 GFpi1kCvjp7iMDR/sPGgW2Fky/FZ3YE= X-MC-Unique: DGDt-pqbNsG28_7TbwuRlg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/12] util: json: Replace virJSONValueObjectSteal by virJSONValueObjectRemoveKey Date: Wed, 6 Jan 2021 15:03:40 +0100 Message-Id: <6e90af722d0d52f26b115bd814e5f5ca2a10cbc8.1609941694.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.22 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 c80c2f1ecb..f85b61957c 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.29.2