Skip to content

Handle fopen() errors

Nguyễn Thái Ngọc Duy git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest15 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSDconfig.mak.uname+3 -00 replies
2/15bisect: report on fopen() errorbisect.c+4 -10 replies
3/15blame: report error on open if graft_file is a directorybuiltin/blame.c+4 -10 replies
4/15clone: use xfopen() instead of fopen()builtin/clone.c+1 -10 replies
5/15log: report errno on failure to fopen() a filebuiltin/log.c+2 -11 reply
6/15commit.c: report error on failure to fopen() the graft filecommit.c+4 -10 replies
7/15remote.c: report error on failure to fopen()remote.c+10 -25 replies
8/15rerere.c: report error on failure to fopen()rerere.c+4 -10 replies
9/15rerere.c: report correct errnorerere.c+3 -20 replies
10/15sequencer.c: report error on failure to fopen()sequencer.c+4 -10 replies
11/15server-info: report error on failure to fopen()server-info.c+4 -10 replies
12/15wt-status.c: report error on failure to fopen()wt-status.c+2 -00 replies
13/15xdiff-interface.c: report errno on failure to stat() or fopen()xdiff-interface.c+2 -20 replies
14/15config.c: handle error on failing to fopen()config.c t/t1308-config-set.sh+10 -20 replies
15/15t1308: add a test case on open a config directoryt/t1308-config-set.sh+9 -00 replies

Reviews trailers per patch

None of the 15 patches has a Reviewed-by or Acked-by.

PatchJeff King
SeriesNoticed-by
1/15
2/15
3/15
4/15
5/15
6/15
7/15
8/15
9/15
10/15
11/15
12/15
13/15
14/15
15/15

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/15] Handle fopen() errors

Some of you may recall a while back, nd/conditional-config-include failed on Windows because I accidentally fopen()'d a directory in a test, but it's not considered an serious error unless it's on Windows, where fopen(<dir>) returns NULL.

A couple of suggestions were thrown back and forth, but I was a bit busy to follow up. Now that I have time, I have audited all fopen() calls and try to fix them up for good. There 15 patches, but they only change one or two lines each. I split them anyway so you can pause between patches and see if it really makes sense, as changes are all over the places.

There are still a few iffy fopen() calls in sequencer.c though. I only fixed the easy ones in there.

The last patch may fail on some platforms since I want to make sure that fopen(<directory>) == NULL is an expected behavior, even though I could only test FreeBSD and Linux (and know Windows behaves the same). At least when people shout up, we could start adding FREAD_READS_DIRECTORIES on those platforms. That's the goal.

Nguyễn Thái Ngọc Duy (15):
config.mak.uname: set FREAD_READS_DIRECTORIES for Linux and FreeBSD
bisect: report on fopen() error
blame: report error on open if graft_file is a directory
clone: use xfopen() instead of fopen()
log: report errno on failure to fopen() a file
commit.c: report error on failure to fopen() the graft file remote.c: report error on failure to fopen()
rerere.c: report error on failure to fopen()
rerere.c: report correct errno
sequencer.c: report error on failure to fopen()
server-info: report error on failure to fopen() wt-status.c: report error on failure to fopen() xdiff-interface.c: report errno on failure to stat() or fopen() config.c: handle error on failing to fopen()
t1308: add a test case on open a config directory

 bisect.c              |  5 ++++-
 builtin/blame.c       |  5 ++++-
 builtin/clone.c       |  2 +-
 builtin/log.c         |  3 ++-
 commit.c              |  5 ++++-
 config.c              |  8 +++++++-
 config.mak.uname      |  3 +++
 remote.c              | 12 ++++++++++--
 rerere.c              | 10 +++++++---
 sequencer.c           |  5 ++++-
 server-info.c         |  5 ++++-
 t/t1308-config-set.sh | 13 ++++++++++++-
 wt-status.c           |  2 ++
 xdiff-interface.c     |  4 ++--
 14 files changed, 66 insertions(+), 16 deletions(-)
Signature · 1 line
2.11.0.157.gd943d85