From nobody Mon Feb 9 10:30:07 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=1646643690; cv=none; d=zohomail.com; s=zohoarc; b=WWfIW3+nENXhhW1A96MG/GLwVGH10By1bx09ZEOj48qVQUOaHANzhwLttNpl2bLDLskBR/cQKIyazQMHa4E/B5Xac2hbPyWwFiHnd5j3Ppjr/MbAZEbyHlTCZUlS/Ja7xShb27u1R7+ak1E2ESlLcF3xQEWENcdRjaPT3SExPX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646643690; 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=sUTz09VaaByxZbhAWBbdMM5zgDPCnVBGAj3h6d7DITM=; b=ZKD6tumXmpLnptdnFLr7ytqd8dNn0XwYXCHfgYvOquqHGYIYrRYUtouR43VJh6suYwGCmEYQhNwkFODluhRPg8DBkhVTTsZmQNiy4k2DIzYeySKQSSxbKC9z/ey1Z0txbcQuMa5N/3yX9A+qSUE+nd2zVlSCtZcSlwsTZxGYWEU= 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) 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 164664369024898.95943438111362; Mon, 7 Mar 2022 01:01:30 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-488-EgzskPuNOeuRB2U1yCaprQ-1; Mon, 07 Mar 2022 04:01:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E02711066697; Mon, 7 Mar 2022 09:01:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id C24D8145FBB4; Mon, 7 Mar 2022 09:01:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 5AB49193058F; Mon, 7 Mar 2022 09:01:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 83BF41931BD1 for ; Mon, 7 Mar 2022 09:01:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 5410A1F470; Mon, 7 Mar 2022 09:01:18 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE9FE1F473 for ; Mon, 7 Mar 2022 09:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646643689; 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=sUTz09VaaByxZbhAWBbdMM5zgDPCnVBGAj3h6d7DITM=; b=ii2APyAYEmPNz2mOAt0wAOqgnp2dMF5FbFndFCpj8lWUhZ6nVYg1Vncra/x9gppoo52Krw hQRGrWDHCqmBt3k6e6Fsjs4tGG80UPAeayQeJ8v71OaE4Kk+bqK7rX0zLmhd0oiv8jd2hb Zb+EDjg+4X34tUWV8BsVz6jJWKDezLA= X-MC-Unique: EgzskPuNOeuRB2U1yCaprQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 10/17] lxc_fuse: Use automatic file closing Date: Mon, 7 Mar 2022 10:01:00 +0100 Message-Id: <447a7af4a3737a0e767e8dcee74e63487db4ee94.1646643526.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 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) X-ZM-MESSAGEID: 1646643691730100003 Content-Type: text/plain; charset="utf-8" There are two functions (lxcProcHostRead() and lxcProcReadMeminfo()) that could benefit from automatic file closing. Signed-off-by: Michal Privoznik --- src/lxc/lxc_fuse.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lxc/lxc_fuse.c b/src/lxc/lxc_fuse.c index 9eff188d5f..1dedbc4069 100644 --- a/src/lxc/lxc_fuse.c +++ b/src/lxc/lxc_fuse.c @@ -126,7 +126,7 @@ lxcProcHostRead(char *path, size_t size, off_t offset) { - int fd; + VIR_AUTOCLOSE fd =3D -1; int res; =20 fd =3D open(path, O_RDONLY); @@ -136,7 +136,6 @@ lxcProcHostRead(char *path, if ((res =3D pread(fd, buf, size, offset)) < 0) res =3D -errno; =20 - VIR_FORCE_CLOSE(fd); return res; } =20 @@ -148,7 +147,7 @@ lxcProcReadMeminfo(char *hostpath, off_t offset) { int res; - FILE *fp =3D NULL; + g_autoptr(FILE) fp =3D NULL; g_autofree char *line =3D NULL; size_t n; struct virLXCMeminfo meminfo; @@ -251,7 +250,6 @@ lxcProcReadMeminfo(char *hostpath, memcpy(buf, virBufferCurrentContent(new_meminfo), res); =20 cleanup: - VIR_FORCE_FCLOSE(fp); return res; } =20 --=20 2.34.1