get-tar-commit-id: check write_in_full() return against 0

We ask to write 41 bytes and make sure that the return value is at least 41. This is the same "dangerous" pattern that was fixed in the prior commit (wherein a negative return value is promoted to unsigned), though it is not dangerous here because our "41" is a constant, not an unsigned variable. But we should convert it anyway to avoid modeling a dangerous construct. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 13, 2017 at 13:11 UTC 68a423ab3e5c160e1162382d2ef0831039b298d4
1 file changed +1 -2
builtin/get-tar-commit-id.c
+1 -2
@@ -33,8 +33,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
33 if (!skip_prefix(content, "52 comment=", &comment))
34 return 1;
35
36 - n = write_in_full(1, comment, 41);
37 - if (n < 41)
36 + if (write_in_full(1, comment, 41) < 0)
37 die_errno("git get-tar-commit-id: write error");
38
39 return 0;