Re: Check some unchecked fclose() results - Mailing list pgsql-hackers

From Andreas Karlsson
Subject Re: Check some unchecked fclose() results
Date
Msg-id 53d0ef41-e11e-4d2a-9aaa-48e9f0cf02f9@proxel.se
Whole thread Raw
In response to Re: Check some unchecked fclose() results  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Check some unchecked fclose() results
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: jie wang
Date:
Subject: Re: Add ParameterDescription message to libpq frontend long message types
Next
From: Tom Lane
Date:
Subject: Re: pg_waldump: support decoding of WAL inside tarfile