Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w86fu-000DaB-0K for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Apr 2026 01:16:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w86fs-003FcE-2n for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Apr 2026 01:16:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w86fs-003Fc0-1W for pgsql-hackers@lists.postgresql.org; Thu, 02 Apr 2026 01:16:44 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w86fo-000000006VC-0y1D for pgsql-hackers@lists.postgresql.org; Thu, 02 Apr 2026 01:16:44 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 546914420E3 for ; Thu, 02 Apr 2026 03:16:34 +0200 (CEST) Received: from s979.loopia.se (unknown [172.22.191.5]) by s807.loopia.se (Postfix) with ESMTP id 3F3FF441DF5; Thu, 02 Apr 2026 03:16:34 +0200 (CEST) Received: from localhost (unknown [172.22.191.5]) by s979.loopia.se (Postfix) with ESMTP id 3ACF510BC3A4; Thu, 02 Apr 2026 03:16:34 +0200 (CEST) X-Virus-Scanned: amavis at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s470.loopia.se (amavis); dkim=pass (2048-bit key) header.d=proxel.se Received: from s934.loopia.se ([172.22.191.5]) by localhost (s470.loopia.se [172.22.190.34]) (amavis, port 10024) with LMTP id CEWhvuMvl6Zy; Thu, 2 Apr 2026 03:16:33 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: andreas@proxel.se X-Loopia-Originating-IP: 147.28.75.140 Received: from [192.168.0.121] (customer-147-28-75-140.stosn.net [147.28.75.140]) (Authenticated sender: andreas@proxel.se) by s934.loopia.se (Postfix) with ESMTPSA id A11D77CEA3A; Thu, 02 Apr 2026 03:16:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proxel.se; s=loopiadkim1707418970; t=1775092593; bh=+im3oFsaPt+G41BHjsf/ro5Pp56WZ8vbZr+0MCXSE0E=; h=Date:Subject:To:References:From:In-Reply-To; b=AI6m1HeaviFdG5gzAGE+Zi4/XrbjVcLi5xgnyiDfdoyAADnOi99xuCULIk5rJhXQf wXWuirzEc8ksV7XhcyP+NkbsP0+KoHOpQzzbi9RczvLIjN202i19NFxiuRQiHEUKXI ZJ3CpWREeYdWzcuqg6VAg0hmpk1EiLQTYpyTJD2NYLTzZ+rSr0BV6PddUyAxSeEwxS aeMf4fUSCLKnkkTTSjg8dZsdckj59Jzxfw737CKMrx9GLLxN6C/6rAIz9LwVZUMfyS ihXijUX5B8yoj+cc3lAtqVYfjQ4iA+LTdaJzvDc+8xcgRZLxMMil1raRbWrQvPEMNZ Qe6HZ3ItIwNJQ== Message-ID: <53d0ef41-e11e-4d2a-9aaa-48e9f0cf02f9@proxel.se> Date: Thu, 2 Apr 2026 03:16:33 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Check some unchecked fclose() results To: Chao Li , PostgreSQL Hackers References: <191398CF-C65F-4751-B704-7C904BCBB80B@gmail.com> From: Andreas Karlsson Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/23/26 3:22 AM, Chao Li wrote: >> My criteria for including cases in this patch were basically: >> >> * only output file descriptors >> * code paths where the logic is relatively clear and easy to handle Those criteria are not enough as can be evidenced from some of the cases which you patched. I do not see why you would want to error out in the following two cases: 1. When writing to e.g. a log file and we do not call pg_fatal() if a write fails. Then it makes no sense to die on failed fclose(). 2. When creating an empty file. I could be wrong here but in that case fclose() cannot fail. Arguably maybe we should use open() and close() then instead of fopen() and fclose() but handling an error which can never happen does not add any value. Please review your patches a bit careful before submitting. You are doing some good work with finding bugs and reviewing patches but it is clear you do not spend enough time per mail making sure it is not a false positive. -- Andreas Karlsson Percona