From nobody Sun Feb 8 20:58:46 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=1630789654; cv=none; d=zohomail.com; s=zohoarc; b=kFDmiv200PEth88mjBb7qBbaJsS4aNjFpm+VoymOmALr4OIHEZfRi1LQO4tb8dsXZT9xs776RzOuVs4ijeWgxdswzuqn0sND9QAb2tdJy8USPV3QXT1VpQW3Lc1zJ+89c41kqVPsuQbpXBN5+gRWSJjZZkP/tvUD92Z8YUUlrSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630789654; 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=+EQVj9DoKONU2cRCJslhLhAgti86J5cnx1OFetgXCx4=; b=JZJyOKVTZhMzQQWhv9wcUcRjpsbEnnGvQ2QFEC6OstbwbomQKES60Jp5W68KYz6Y5+iv+XbfRaXOtIBjdygtG9meZABk9tdeYN72TOq1gjKT6Mip5r1wgaecBBRUNTJGsgpJZ/UPqUf0spX26LGdFhgc1MpfivJgMIQVbRKdfbc= 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) 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 1630789654545473.46062395903584; Sat, 4 Sep 2021 14:07:34 -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-329-gsLoQnAINyueY43lUVkrjg-1; Sat, 04 Sep 2021 17:07:32 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1EBD9FC80; Sat, 4 Sep 2021 21:07:27 +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 026A677BE7; Sat, 4 Sep 2021 21:07:27 +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 C8D9144A63; Sat, 4 Sep 2021 21:07:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 184KiefR008863 for ; Sat, 4 Sep 2021 16:44:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0D6862619D; Sat, 4 Sep 2021 20:44:40 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AB251F4 for ; Sat, 4 Sep 2021 20:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630789653; 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=+EQVj9DoKONU2cRCJslhLhAgti86J5cnx1OFetgXCx4=; b=BgY+jxy5zVcaAnYXzfjqEUo0Dqp0wrX7MNIabK9VJ3MbN1Uofkf9046P8lV4iGePO7/rJp W2knHLCGKxvd4jdRqxa1mOfEJoqbdCcOjc7w5lL/oYn/JzmiPIP7zE/4/SKiLEDz5zpSbV OJHK0w2M8kOHgG8Q7R1k3VjeBeLg8ak= X-MC-Unique: gsLoQnAINyueY43lUVkrjg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 15/24] tests: use VIR_AUTOCLOSE Date: Sat, 4 Sep 2021 22:44:13 +0200 Message-Id: <9f3f7b3750b913e6f74999272a2ca0e8d8f493b4.1630788206.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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.13 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630789656251100003 Signed-off-by: J=C3=A1n Tomko --- tests/fdstreamtest.c | 6 ++---- tests/scsihosttest.c | 3 +-- tests/virfiletest.c | 6 ++---- tests/virnettlshelpers.c | 4 +--- tests/virpcimock.c | 4 +--- tests/virrotatingfiletest.c | 4 +--- 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tests/fdstreamtest.c b/tests/fdstreamtest.c index 182c853b33..96519e91c2 100644 --- a/tests/fdstreamtest.c +++ b/tests/fdstreamtest.c @@ -38,7 +38,7 @@ VIR_LOG_INIT("tests.fdstreamtest"); =20 static int testFDStreamReadCommon(const char *scratchdir, bool blocking) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *file =3D NULL; int ret =3D -1; g_autofree char *pattern =3D NULL; @@ -144,7 +144,6 @@ static int testFDStreamReadCommon(const char *scratchdi= r, bool blocking) cleanup: if (st) virStreamFree(st); - VIR_FORCE_CLOSE(fd); if (file !=3D NULL) unlink(file); if (conn) @@ -165,7 +164,7 @@ static int testFDStreamReadNonblock(const void *data) =20 static int testFDStreamWriteCommon(const char *scratchdir, bool blocking) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *file =3D NULL; int ret =3D -1; g_autofree char *pattern =3D NULL; @@ -284,7 +283,6 @@ static int testFDStreamWriteCommon(const char *scratchd= ir, bool blocking) cleanup: if (st) virStreamFree(st); - VIR_FORCE_CLOSE(fd); if (file !=3D NULL) unlink(file); if (conn) diff --git a/tests/scsihosttest.c b/tests/scsihosttest.c index 336b3cc496..aeb91da691 100644 --- a/tests/scsihosttest.c +++ b/tests/scsihosttest.c @@ -71,7 +71,7 @@ create_scsihost(const char *fakesysfsdir, const char *dev= icepath, g_autofree char *link_path =3D NULL; char *spot; int ret =3D -1; - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; =20 unique_id_path =3D g_strdup_printf("%s/devices/pci0000:00/%s/unique_id= ", fakesysfsdir, devicepath); @@ -136,7 +136,6 @@ create_scsihost(const char *fakesysfsdir, const char *d= evicepath, ret =3D 0; =20 cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 diff --git a/tests/virfiletest.c b/tests/virfiletest.c index 019c230cea..a6e722b4d2 100644 --- a/tests/virfiletest.c +++ b/tests/virfiletest.c @@ -194,7 +194,7 @@ holesSupported(void) { off_t offsets[] =3D {EXTENT, EXTENT, EXTENT, -1}; off_t tmp; - int fd; + VIR_AUTOCLOSE fd =3D -1; bool ret =3D false; =20 if ((fd =3D makeSparseFile(offsets, true)) < 0) @@ -229,7 +229,6 @@ holesSupported(void) =20 ret =3D true; cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 @@ -261,7 +260,7 @@ static int testFileInData(const void *opaque) { const struct testFileInData *data =3D opaque; - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; int ret =3D -1; size_t i; =20 @@ -303,7 +302,6 @@ testFileInData(const void *opaque) ret =3D 0; =20 cleanup: - VIR_FORCE_CLOSE(fd); return ret; } =20 diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index 905e633e60..c9e2b372bb 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -396,7 +396,7 @@ void testTLSWriteCertChain(const char *filename, size_t ncerts) { size_t i; - int fd; + VIR_AUTOCLOSE fd =3D -1; int err; static char buffer[1024*1024]; size_t size; @@ -420,8 +420,6 @@ void testTLSWriteCertChain(const char *filename, abort(); } } - - VIR_FORCE_CLOSE(fd); } =20 =20 diff --git a/tests/virpcimock.c b/tests/virpcimock.c index ead810d412..d4d43aac51 100644 --- a/tests/virpcimock.c +++ b/tests/virpcimock.c @@ -177,7 +177,7 @@ make_file(const char *path, const char *value, ssize_t len) { - int fd =3D -1; + VIR_AUTOCLOSE fd =3D -1; g_autofree char *filepath =3D NULL; if (value && len =3D=3D -1) len =3D strlen(value); @@ -189,8 +189,6 @@ make_file(const char *path, =20 if (value && safewrite(fd, value, len) !=3D len) ABORT("Unable to write: %s", filepath); - - VIR_FORCE_CLOSE(fd); } =20 static void diff --git a/tests/virrotatingfiletest.c b/tests/virrotatingfiletest.c index 87699936cb..ede65848ea 100644 --- a/tests/virrotatingfiletest.c +++ b/tests/virrotatingfiletest.c @@ -125,7 +125,7 @@ static int testRotatingFileInitOne(const char *filename, unlink(filename); } else { char buf[1024]; - int fd; + VIR_AUTOCLOSE fd =3D -1; =20 VIR_DEBUG("Creating %s size %zu", filename, (size_t)size); =20 @@ -142,12 +142,10 @@ static int testRotatingFileInitOne(const char *filena= me, =20 if (safewrite(fd, buf, towrite) !=3D towrite) { fprintf(stderr, "Cannot write to %s\n", filename); - VIR_FORCE_CLOSE(fd); return -1; } size -=3D towrite; } - VIR_FORCE_CLOSE(fd); } return 0; } --=20 2.31.1