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

From Chao Li
Subject Check some unchecked fclose() results
Date
Msg-id 191398CF-C65F-4751-B704-7C904BCBB80B@gmail.com
Whole thread Raw
Responses Re: Check some unchecked fclose() results
List pgsql-hackers
Hi,

This morning, while reading through recent commits, I noticed that 69c57466a added a check for fclose(), with the
explanationthat “write errors (like ENOSPC) may not be reported until close time.” More generally, an fclose() failure
canalso reflect an earlier buffered write or flush failure that is only reported when the stream is closed. So it seems
worthchecking these calls in other file-writing paths as well. 

So I did a quick search through the source tree, and I found several other fclose() calls whose results are not
checked.This patch fixes some of them. 

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

If this patch gets processed, I would be happy to spend more time handling the remaining cases. Or, if committers think
allremaining cases should be included in this patch, I would also be happy to expand it. 

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/







pgsql-hackers by date:

Previous
From: Jianghua Yang
Date:
Subject: Re: basebackup: add missing deflateEnd() in gzip compression sink
Next
From: jian he
Date:
Subject: Re: CREATE TABLE LIKE INCLUDING TRIGGERS