From nobody Tue Feb 10 07:39:07 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=1612600418; cv=none; d=zohomail.com; s=zohoarc; b=jkfjQ98WXdmZFUlroqTUexKdB9qTxB61vsVcOWwoxs1OSs3mFNNvLih6IU34rv8+hjwh57+KFOyGmp+Thl9mh0nuCXC1V4zno31lqMxmGhpNgOnJTwTPWz9+yHuP2ejO6LjyfghlvevtyFW23wKUG6eCMCRv/8I7ak4JQmBIHQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612600418; 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=UYIUiwgn1HiEWuwQlgXz8skoHTaZbqMLtK74gr4cRLk=; b=LEIB3omTRQjL3L8r464VEaUocybGjk/QuubJ7ZAeJIYIcSsKF5LpaHF9sOtyL/mtQKygagM7Aj2xYDoabyK0O2YpF4Av2SaYaVt4Ky7PfqUquGQ5UIrPJvjf0WyyvZcaXSq2q5+EFpQAQvfdY2dZPcJAfKCINf+ySSIBKYPRS8g= 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 1612600418954201.64298636357069; Sat, 6 Feb 2021 00:33:38 -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-479-9w43n0pqNKqPaX6YRPiZsw-1; Sat, 06 Feb 2021 03:33:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E2F57100CCC2; Sat, 6 Feb 2021 08:33:29 +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 BFCCD62954; Sat, 6 Feb 2021 08:33:29 +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 8907E18095CE; Sat, 6 Feb 2021 08:33:29 +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 1168XAHl004668 for ; Sat, 6 Feb 2021 03:33:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9A55960C77; Sat, 6 Feb 2021 08:33:10 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6B2360C76 for ; Sat, 6 Feb 2021 08:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612600418; 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=UYIUiwgn1HiEWuwQlgXz8skoHTaZbqMLtK74gr4cRLk=; b=gagcnFHnm0EIZUNCxqXf0laHDRR3MALdkGkVE2mfqcuQvtSkk1LIp4FIADkvkk7+lp57tP 8uKs/636ZdPZ+9CQJVrqcyFvWa4se1DWEIKZ8lfF/49XdatfxX4Vt/sNY1zY5ESvjFj72+ gAKidmIq3VJbTvoz+BfbI2HtZMs73Rc= X-MC-Unique: 9w43n0pqNKqPaX6YRPiZsw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/40] util: virmacmap: Use g_autofree for virJSONValue Date: Sat, 6 Feb 2021 09:32:24 +0100 Message-Id: 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.15 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" Signed-off-by: Peter Krempa --- src/util/virmacmap.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/util/virmacmap.c b/src/util/virmacmap.c index e68742de10..0abb6cf580 100644 --- a/src/util/virmacmap.c +++ b/src/util/virmacmap.c @@ -130,7 +130,7 @@ virMacMapLoadFile(virMacMapPtr mgr, const char *file) { g_autofree char *map_str =3D NULL; - virJSONValuePtr map =3D NULL; + g_autoptr(virJSONValue) map =3D NULL; int map_str_len =3D 0; size_t i; int ret =3D -1; @@ -189,7 +189,6 @@ virMacMapLoadFile(virMacMapPtr mgr, ret =3D 0; cleanup: - virJSONValueFree(map); return ret; } @@ -199,14 +198,12 @@ virMACMapHashDumper(void *payload, const char *name, void *data) { - virJSONValuePtr obj =3D virJSONValueNewObject(); - virJSONValuePtr arr =3D NULL; + g_autoptr(virJSONValue) obj =3D virJSONValueNewObject(); + g_autoptr(virJSONValue) arr =3D virJSONValueNewArray(); const char **macs =3D payload; size_t i; int ret =3D -1; - arr =3D virJSONValueNewArray(); - for (i =3D 0; macs[i]; i++) { virJSONValuePtr m =3D virJSONValueNewString(macs[i]); @@ -228,8 +225,6 @@ virMACMapHashDumper(void *payload, ret =3D 0; cleanup: - virJSONValueFree(obj); - virJSONValueFree(arr); return ret; } @@ -238,11 +233,9 @@ static int virMacMapDumpStrLocked(virMacMapPtr mgr, char **str) { - virJSONValuePtr arr; + g_autoptr(virJSONValue) arr =3D virJSONValueNewArray(); int ret =3D -1; - arr =3D virJSONValueNewArray(); - if (virHashForEachSorted(mgr->macs, virMACMapHashDumper, arr) < 0) goto cleanup; @@ -251,7 +244,6 @@ virMacMapDumpStrLocked(virMacMapPtr mgr, ret =3D 0; cleanup: - virJSONValueFree(arr); return ret; } --=20 2.29.2