From nobody Mon Feb 9 07:23:25 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=1603849006; cv=none; d=zohomail.com; s=zohoarc; b=VhrreoZnweubR19oyfBTtZgSLCMCWMxanJGlWvps0KIIb9fl1xlorIItVqE0kqERqXfWok2ayoO9Wh1MD5QWbfOUcnbMkld3KRtnSXloNdAqg6dAnREHQ7yVhh4M5Vg8nJatpgrQHT1DQlS6iFywxXzkOBh2Q3r6MbPZ0oCCILQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603849006; 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=zKHDXxI9YqoGl25WcGRHrELmnqvhxyAR7hPmEecJ3DE=; b=TBi9gonAzgX8+uyLkESHYBvSbAlVQjfiODewNTXcCgtEmb91MlTUB9qQdqisEpDZZ1DVeme85ewJwgNbM6OQ3gcz3ShVH4W0kNzxI/TJHEJzOaZ6UUrSHLlIQMlwHChfq1TaonRWBFX6GpeiJdx8yW6yTf5LbrUDG3PVMuluEbY= 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 160384900644712.19199899478292; Tue, 27 Oct 2020 18:36:46 -0700 (PDT) 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-340-yb38IspuMfyAt4-x6Ocj9Q-1; Tue, 27 Oct 2020 21:36:43 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6300B760CE; Wed, 28 Oct 2020 01:36:34 +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 435815B4C1; Wed, 28 Oct 2020 01:36:34 +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 134F9CF5F; Wed, 28 Oct 2020 01:36:34 +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 09S1aDXL028301 for ; Tue, 27 Oct 2020 21:36:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 67CBA5C1DC; Wed, 28 Oct 2020 01:36:13 +0000 (UTC) Received: from vhost2.laine.org (ovpn-113-144.phx2.redhat.com [10.3.113.144]) by smtp.corp.redhat.com (Postfix) with ESMTP id B09165C22A for ; Wed, 28 Oct 2020 01:36:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603849005; 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=zKHDXxI9YqoGl25WcGRHrELmnqvhxyAR7hPmEecJ3DE=; b=Yxty+iGYobKB+WeR40PQANJGLFxEinYUy+1chlj1NqA77Rr+Ch3RrCEMdhGTb59EsIms2E RzS73Iqh39OpSIQ9/NyhElqN7hGcrw2IoKbwuljh0/XeKEYXvMYTcrY+U9x4pLziVUm21n CCeroi45kp76u+UjscA/Db9ZCcL6MAs= X-MC-Unique: yb38IspuMfyAt4-x6Ocj9Q-1 From: Laine Stump To: libvir-list@redhat.com Subject: [PATCH 09/12] conf: convert final DIR* to g_autoptr Date: Tue, 27 Oct 2020 21:35:55 -0400 Message-Id: <20201028013558.424925-10-laine@redhat.com> In-Reply-To: <20201028013558.424925-1-laine@redhat.com> References: <20201028013558.424925-1-laine@redhat.com> 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.11 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" This use of DIR* was re-using the same function-scope DIR* each time through a for loop, and due to multiple error gotos in the loop, it needed to have the scope of the DIR* reduced to just the loop at the same time as switching to g_autoptr. That's what this patch does. Signed-off-by: Laine Stump --- src/conf/capabilities.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 18b2612d2e..425f34113a 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -1837,7 +1837,6 @@ virCapabilitiesInitCaches(virCapsPtr caps) size_t i =3D 0; virBitmapPtr cpus =3D NULL; ssize_t pos =3D -1; - DIR *dirp =3D NULL; int ret =3D -1; char *path =3D NULL; char *type =3D NULL; @@ -1860,13 +1859,11 @@ virCapabilitiesInitCaches(virCapsPtr caps) =20 while ((pos =3D virBitmapNextSetBit(cpus, pos)) >=3D 0) { int rv =3D -1; + g_autoptr(DIR) dirp =3D NULL; =20 VIR_FREE(path); path =3D g_strdup_printf("%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH= , pos); =20 - VIR_DIR_CLOSE(dirp); - dirp =3D NULL; - rv =3D virDirOpenIfExists(&dirp, path); if (rv < 0) goto cleanup; @@ -1971,7 +1968,6 @@ virCapabilitiesInitCaches(virCapsPtr caps) cleanup: VIR_FREE(type); VIR_FREE(path); - VIR_DIR_CLOSE(dirp); virCapsHostCacheBankFree(bank); virBitmapFree(cpus); return ret; --=20 2.26.2