From: Junio C Hamano Date: Mon, 23 Oct 2017 05:37:21 +0000 (+0900) Subject: Merge branch 'jk/write-in-full-fix' into maint X-Git-Tag: v2.14.3~3 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/96c6bb566ee5354a1b07530a94d3f85055e46032 Merge branch 'jk/write-in-full-fix' into maint Many codepaths did not diagnose write failures correctly when disks go full, due to their misuse of write_in_full() helper function, which have been corrected. * jk/write-in-full-fix: read_pack_header: handle signed/unsigned comparison in read result config: flip return value of store_write_*() notes-merge: use ssize_t for write_in_full() return value pkt-line: check write_in_full() errors against "< 0" convert less-trivial versions of "write_in_full() != len" avoid "write_in_full(fd, buf, len) != len" pattern get-tar-commit-id: check write_in_full() return against 0 config: avoid "write_in_full(fd, buf, len) < len" pattern --- 96c6bb566ee5354a1b07530a94d3f85055e46032 diff --cc pkt-line.c index f364944b93,4823d3bb9d..647bbd3bce --- a/pkt-line.c +++ b/pkt-line.c @@@ -136,20 -136,18 +136,19 @@@ static void format_packet(struct strbu static int packet_write_fmt_1(int fd, int gently, const char *fmt, va_list args) { - struct strbuf buf = STRBUF_INIT; + static struct strbuf buf = STRBUF_INIT; - ssize_t count; + strbuf_reset(&buf); format_packet(&buf, fmt, args); - count = write_in_full(fd, buf.buf, buf.len); - if (count == buf.len) - return 0; - - if (!gently) { - check_pipe(errno); - die_errno("packet write with format failed"); + if (write_in_full(fd, buf.buf, buf.len) < 0) { + if (!gently) { + check_pipe(errno); + die_errno("packet write with format failed"); + } + return error("packet write with format failed"); } - return error("packet write with format failed"); + + return 0; } void packet_write_fmt(int fd, const char *fmt, ...)