From nobody Mon Feb 9 10:27:30 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=1613167679; cv=none; d=zohomail.com; s=zohoarc; b=oBwVBlo6qW3m5INnEMefp4FhtcgC6TYoc+9J96nAr4n4ptJqPSr47v2vjZ/Xf5NDx3qmekK0jfRmcVUbtD7UCFkeGOKIj9Kcbxhp4MCxC3orUs8V6qt+JqbmsKnXA+42NEKY7yiFtvKoGLNWLruZuUBR1hZgGrfX2Yu9nf1USRg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613167679; 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=LP6rGd3l8sUEWj5LgsXbJqVdBDJYmYy/JED/7ZO8fko=; b=XQV0SE8RF865TdCpJQHTtVx+N3L/is/7f9SESmkWuo9ayZfBZVPbcIAe21OSnyYu1L6F0m6Z+nqFjngtBsuZunDmOOt6mWcsch9am3I48Kjj7as9ZBDG9xJ5ZyfdbpHGn7lfKpoPrX2rkR/m4YvB8uM34rPzgRePX5FZaWevsRA= 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 1613167679861470.3601413053673; Fri, 12 Feb 2021 14:07:59 -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-175-5dNYmCsTPOGdz9m14RV-HA-1; Fri, 12 Feb 2021 17:07:51 -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 E89E71966320; Fri, 12 Feb 2021 22:07:44 +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 C5BA96267B; Fri, 12 Feb 2021 22:07:44 +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 8FE67EDCE; Fri, 12 Feb 2021 22:07:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11CM7PSo006181 for ; Fri, 12 Feb 2021 17:07:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id F3C831001E73; Fri, 12 Feb 2021 22:07:24 +0000 (UTC) Received: from vhost2.router.laine.org (ovpn-112-48.phx2.redhat.com [10.3.112.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBCE11002388 for ; Fri, 12 Feb 2021 22:07:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613167673; 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=LP6rGd3l8sUEWj5LgsXbJqVdBDJYmYy/JED/7ZO8fko=; b=d/PEkjpH6XF192WHF6xfNlNJemmtcvmkpx5aP2fNTpBDSP7BEn5lQQq7Sz8cAPWxbJJXVH As05Z9A/YNy/WC/r2f1I3aMEhq8ZomfYH5cielsom4gd81ee75XS2FYnrlo1PhpMMwAxAh mj0haRp8777IhnMRpuyR0MIsZwnRoNc= X-MC-Unique: 5dNYmCsTPOGdz9m14RV-HA-1 From: Laine Stump To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] esx: replace some VIR_FREE with g_clear_pointer(x, g_free) Date: Fri, 12 Feb 2021 17:07:17 -0500 Message-Id: <20210212220717.910294-10-laine@redhat.com> In-Reply-To: <20210212220717.910294-1-laine@redhat.com> References: <20210212220717.910294-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 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" These are all cases when 1) the pointer is passed by reference from the caller (ie.e. **) and expects it to be NULL on return if there is an error, or 2) the variable holding the pointer is being checked or re-used in the same function, but not right away. Signed-off-by: Laine Stump --- src/esx/esx_network_driver.c | 2 +- src/esx/esx_util.c | 8 ++++---- src/esx/esx_vi.c | 4 ++-- src/esx/esx_vi_types.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index b489f4de8a..4d0fba8c9f 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -914,7 +914,7 @@ esxConnectListAllNetworks(virConnectPtr conn, if (nets && *nets) { for (i =3D 0; i < count; ++i) g_free((*nets)[i]); - VIR_FREE(*nets); + g_clear_pointer(nets, g_free); } } =20 diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index ef070a4f04..24e1c73ec4 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -95,7 +95,7 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr= uri) /* Expected format: [://][:] */ (*parsedUri)->proxy =3D true; (*parsedUri)->proxy_type =3D CURLPROXY_HTTP; - VIR_FREE((*parsedUri)->proxy_hostname); + g_clear_pointer(&(*parsedUri)->proxy_hostname, g_free); (*parsedUri)->proxy_port =3D 1080; =20 if ((tmp =3D STRSKIP(queryParam->value, "http://"))) { @@ -261,13 +261,13 @@ esxUtil_ParseDatastorePath(const char *datastorePath,= char **datastoreName, cleanup: if (result < 0) { if (datastoreName) - VIR_FREE(*datastoreName); + g_clear_pointer(datastoreName, g_free); =20 if (directoryName) - VIR_FREE(*directoryName); + g_clear_pointer(directoryName, g_free); =20 if (directoryAndFileName) - VIR_FREE(*directoryAndFileName); + g_clear_pointer(directoryAndFileName, g_free); } =20 return result; diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index db5035c035..e1c1a15ab6 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -73,7 +73,7 @@ VIR_LOG_INIT("esx.esx_vi"); \ _body \ \ - VIR_FREE(*ptrptr); \ + g_clear_pointer(ptrptr, g_free); \ } =20 =20 @@ -2516,7 +2516,7 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *= virtualMachine, =20 failure: if (name) - VIR_FREE(*name); + g_clear_pointer(name, g_free); =20 return -1; } diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 4dc7c30680..59735194ae 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -67,7 +67,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); \ _body \ \ - VIR_FREE(*ptrptr); \ + g_clear_pointer(ptrptr, g_free); \ } =20 =20 --=20 2.29.2