Subject: [PATCH 00/15] Handle fopen() errors

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Thu, 20 Apr 2017 18:25:54 +0700

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(-)

-- 
2.11.0.157.gd943d85