From b2c565ec38cec215cb96faeb1a226a44d98b34b1 Mon Sep 17 00:00:00 2001 From: Adam Borowski <kilobyte@angband.pl> Date: Tue, 10 May 2022 16:31:50 +0200 Subject: [PATCH] test: don't use a FILE pointer after fclose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 12 considers this wrong: ut_file.c:92:17: error: pointer ‘stream’ may be used after ‘fclose’ [-Werror=use-after-free] In our case the pointer doesn't actually get dereferenced -- but then, knowing its no longer valid value doesn't help in debugging, thus there's no point in arguing with the compiler. --- src/test/unittest/ut_file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/unittest/ut_file.c b/src/test/unittest/ut_file.c index 54cb1bb6f..29e81b514 100644 --- a/src/test/unittest/ut_file.c +++ b/src/test/unittest/ut_file.c @@ -88,10 +88,8 @@ ut_fclose(const char *file, int line, const char *func, FILE *stream) { int retval = os_fclose(stream); - if (retval != 0) { - ut_fatal(file, line, func, "!fclose: 0x%llx", - (unsigned long long)stream); - } + if (retval != 0) + ut_fatal(file, line, func, "!fclose"); return retval; } -- GitLab