untracked: fix detection of uname(2) failure
authorCharles Bailey <cbailey32@bloomberg.net>
Fri, 17 Jul 2015 17:09:41 +0000 (18:09 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 17 Jul 2015 21:39:59 +0000 (14:39 -0700)
According to POSIX specification uname(2) must return -1 on failure
and a non-negative value on success. Although many implementations
do return 0 on success it is valid to return any positive value for
success. In particular, Solaris returns 1.

Signed-off-by: Charles Bailey <cbailey32@bloomberg.net>
Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
diff --git a/dir.c b/dir.c
index e9eaf97efec17e4e96c3ee6cc09e7d4a74304f6d..8d15e475d420ea13b39e07644fa987c75317ea94 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1801,7 +1801,7 @@ static const char *get_ident_string(void)
 
        if (sb.len)
                return sb.buf;
-       if (uname(&uts))
+       if (uname(&uts) < 0)
                die_errno(_("failed to get kernel name and information"));
        strbuf_addf(&sb, "Location %s, system %s %s %s", get_git_work_tree(),
                    uts.sysname, uts.release, uts.version);