Skip to content

Commit

Permalink
git_mkstemps: correctly test return value of open()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dale R. Worley authored and Junio C Hamano committed Jul 12, 2013
1 parent 62e91ef commit a2cb86c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
template[5] = letters[v % num_letters]; v /= num_letters;

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

0 comments on commit a2cb86c

Please sign in to comment.