Browse Source

git_mkstemps: correctly test return value of open()

open() returns -1 on failure, and indeed 0 is a possible success value
if the user closed stdin in our process.  Fix the test.

Signed-off-by: Thomas Rast <trast@inf.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Dale R. Worley 12 years ago committed by Junio C Hamano
parent
commit
a2cb86c152
  1. 2
      wrapper.c

2
wrapper.c

@ -322,7 +322,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
template[5] = letters[v % num_letters]; v /= num_letters; template[5] = letters[v % num_letters]; v /= num_letters;


fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode); fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
if (fd > 0) if (fd >= 0)
return fd; return fd;
/* /*
* Fatal error (EPERM, ENOSPC etc). * Fatal error (EPERM, ENOSPC etc).

Loading…
Cancel
Save