From nobody Tue Feb 10 07:40:12 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1613152642; cv=none; d=zohomail.com; s=zohoarc; b=EQWERMjpqo3rzeCtQhCsUy8/qNNapwCJQ6PG1EsvWqEIOEtCE9wOYla3rlKFgO8K2pIwmozpIGwWM3lDCgrMuAW/v4470tD5ULWQw00FXCXLN6LEeNZpFlWK36PKWFnSgm/AZ7HrRJctcJQ3nH4su07LHuEhliTlMhR/PpL0aD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613152642; 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=L7DzOAZRcupOATo9w41tJ5iAltKmvngeMNl8heo8R7M=; b=fbN3im2LCi4+94/OAe+ABYlkOlR4k6ljYyLwb4VmF74kLRXkE8WzRySHvB/bXiJEteQlZ4iAZqUgo+PG7BUfuTzcSnXkU4f3gTrq6bHY3HPl8JJ+9dO9fQfA/BgtIQPYt90KTO0/uNdU71iRuK0QaukvPfYCueMK7ORmQvBFBqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1613152642216791.8671943769206; Fri, 12 Feb 2021 09:57: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-576-3Zk612D8OnOd7W2w6t43fQ-1; Fri, 12 Feb 2021 12:57:14 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EE851087D62; Fri, 12 Feb 2021 17:56:40 +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 EC9F460C17; Fri, 12 Feb 2021 17:56:39 +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 B01E61809C90; Fri, 12 Feb 2021 17:56:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CHucH4010894 for ; Fri, 12 Feb 2021 12:56:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1E6FE5C8BE; Fri, 12 Feb 2021 17:56:38 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 660BB5C3E0 for ; Fri, 12 Feb 2021 17:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613152638; 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=L7DzOAZRcupOATo9w41tJ5iAltKmvngeMNl8heo8R7M=; b=ObFW6yuHO6OXAyOyt0XLdUHxteOX26SaHx/6G5Kx1TTOi5ghk1pWMD1KI/wMCdC+7HjLlE NZDUn7XQMIoonpmgRdjrkbLXGDHB5JB0Ycl0fk0G1q3cNXHkMWbxUakEFgszE/JL2SZKcM MPGvae7djSUDAR6pkIigPVA7XILJNyY= X-MC-Unique: 3Zk612D8OnOd7W2w6t43fQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/25] virJSONValueNewArrayFromBitmap: Refactor cleanup Date: Fri, 12 Feb 2021 18:55:27 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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" Use g_autoptr for the JSON value objects and remove the cleanup label and inline freeing of objects. Signed-off-by: Peter Krempa --- src/util/virjson.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index adf1cfbcbc..e4d71d3e09 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1241,29 +1241,21 @@ virJSONValueGetArrayAsBitmap(const virJSONValue *va= l, virJSONValuePtr virJSONValueNewArrayFromBitmap(virBitmapPtr bitmap) { - virJSONValuePtr ret; + g_autoptr(virJSONValue) ret =3D virJSONValueNewArray(); ssize_t pos =3D -1; - ret =3D virJSONValueNewArray(); - if (!bitmap) - return ret; + return g_steal_pointer(&ret); while ((pos =3D virBitmapNextSetBit(bitmap, pos)) > -1) { - virJSONValuePtr newelem; + g_autoptr(virJSONValue) newelem =3D virJSONValueNewNumberLong(pos); - if (!(newelem =3D virJSONValueNewNumberLong(pos)) || - virJSONValueArrayAppend(ret, newelem) < 0) { - virJSONValueFree(newelem); - goto error; - } + if (virJSONValueArrayAppend(ret, newelem) < 0) + return NULL; + newelem =3D NULL; } - return ret; - - error: - virJSONValueFree(ret); - return NULL; + return g_steal_pointer(&ret); } --=20 2.29.2