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>
Dale R. Worley committed
Jul 12, 2013 at 10:58 UTC
a2cb86c1524b7af20e609ca8d3db0b60b5c1d575
1 file changed
+1
-1
wrapper.c
+1
-1
@@ -322,7 +322,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
322
template[5] = letters[v % num_letters]; v /= num_letters;
323
324
fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
325
- if (fd > 0)
325
+ if (fd >= 0)
326
return fd;
327
/*
328
* Fatal error (EPERM, ENOSPC etc).