]> granicus.if.org Git - git/commitdiff
git_mkstemps: correctly test return value of open()
authorDale R. Worley <worley@alum.mit.edu>
Fri, 12 Jul 2013 08:58:35 +0000 (10:58 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Jul 2013 17:30:08 +0000 (10:30 -0700)
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>
wrapper.c

index bac59d2c41bae7441038b30728c696b6280f4c2d..094b2ab9836a4d1d13d432982c6b2582ee3cb13a 100644 (file)
--- a/wrapper.c
+++ b/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;
 
                fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
-               if (fd > 0)
+               if (fd >= 0)
                        return fd;
                /*
                 * Fatal error (EPERM, ENOSPC etc).