From nobody Mon Feb 9 01:48:40 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=1662639969; cv=none; d=zohomail.com; s=zohoarc; b=FWvISwKySyNg2/z9liUpAGEIxhRwU6TmcnT7IvrlnDpEzlGEOHk/hLSNDINBtdMWlWgUWEb+fz+VJ6P1q8Sb+vfEbLXd547qIB2W1xgZiArXjA6KR0RSBznZWVHbD7yMa0NPuIvnNFv72LZl0WphnXVVx28kMjO5g1qQHm57mCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662639969; 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=2+0+kaPSnYwtKYr25rFL9P/ZTLbree7A3dOE1mrkypw=; b=nN/5WaIJHUNzaI8MnD9+eivlsO1k7KJsGyEr82KNg5L5qN/PwuDhookPtoYPF/rjV8FTtpRraiQkug/KMBKbnH77a+4PFb4+8AJv6iXAMJT9jQpzUIAJXE7MBVGVBEunLN66Y7nmC1nqoA4dK0pQmhY75WQiZ1adEw2QYWONeEk= 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 166263996909610.98165474017162; Thu, 8 Sep 2022 05:26:09 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-nxsEsQsdNTOoh1RRqs3pmA-1; Thu, 08 Sep 2022 08:25:34 -0400 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 948D93C10257; Thu, 8 Sep 2022 12:25:09 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D3E114152E3; Thu, 8 Sep 2022 12:25:09 +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 6D7F41946A44; Thu, 8 Sep 2022 12:25:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C22091946A44 for ; Thu, 8 Sep 2022 12:25:07 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B60D22166B29; Thu, 8 Sep 2022 12:25:07 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D1912166B26 for ; Thu, 8 Sep 2022 12:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662639968; 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=2+0+kaPSnYwtKYr25rFL9P/ZTLbree7A3dOE1mrkypw=; b=TIx7mG2I8Gps/KAFpyR1tZ9JbohNn5ySzB7XtpDtj3lL1ewcK3NEqsTCoGoiMF8SdL8pd0 oef4jtzgc1yCXl+DtgJfLBLd68SRmGXD1Ss2hOWJBrudWRargSazHRcQUcr0o8On/3MVtu tq5VAzOiOeBHNaferXyQCDmiRR3Bazg= X-MC-Unique: nxsEsQsdNTOoh1RRqs3pmA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 1/5] lxc: virLXCProcessReadLogOutput: Automatically close FD Date: Thu, 8 Sep 2022 14:25:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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 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: 1662639970928100001 Content-Type: text/plain; charset="utf-8" Switch to 'VIR_AUTOCLOSE' to simplify cleanup. Signed-off-by: Peter Krempa --- src/lxc/lxc_process.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index fe5cab3df6..39dcf53c67 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1076,8 +1076,7 @@ virLXCProcessReadLogOutput(virDomainObj *vm, char *buf, size_t buflen) { - int fd =3D -1; - int ret; + VIR_AUTOCLOSE fd =3D -1; if ((fd =3D open(logfile, O_RDONLY)) < 0) { virReportSystemError(errno, @@ -1090,17 +1089,10 @@ virLXCProcessReadLogOutput(virDomainObj *vm, virReportSystemError(errno, _("Unable to seek log file %s to %llu"), logfile, (unsigned long long)pos); - VIR_FORCE_CLOSE(fd); return -1; } - ret =3D virLXCProcessReadLogOutputData(vm, - fd, - buf, - buflen); - - VIR_FORCE_CLOSE(fd); - return ret; + return virLXCProcessReadLogOutputData(vm, fd, buf, buflen); } --=20 2.37.1