diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-23 14:37:21 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-23 14:37:22 +0900 |
commit | 96c6bb566ee5354a1b07530a94d3f85055e46032 (patch) | |
tree | 675b4ea93a5c4ffd9db000608d23a794f6cf7d4e /builtin | |
parent | Merge branch 'rj/no-sign-compare' into maint (diff) | |
parent | read_pack_header: handle signed/unsigned comparison in read result (diff) | |
download | tgif-96c6bb566ee5354a1b07530a94d3f85055e46032.tar.xz |
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
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/get-tar-commit-id.c | 3 | ||||
-rw-r--r-- | builtin/receive-pack.c | 2 | ||||
-rw-r--r-- | builtin/rerere.c | 2 | ||||
-rw-r--r-- | builtin/unpack-file.c | 2 |
4 files changed, 4 insertions, 5 deletions
diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c index e21c5416cd..6d9a79f9b3 100644 --- a/builtin/get-tar-commit-id.c +++ b/builtin/get-tar-commit-id.c @@ -33,8 +33,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix) if (!skip_prefix(content, "52 comment=", &comment)) return 1; - n = write_in_full(1, comment, 41); - if (n < 41) + if (write_in_full(1, comment, 41) < 0) die_errno("git get-tar-commit-id: write error"); return 0; diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index cabdc55e09..01dea59f58 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -742,7 +742,7 @@ static int run_and_feed_hook(const char *hook_name, feed_fn feed, size_t n; if (feed(feed_state, &buf, &n)) break; - if (write_in_full(proc.in, buf, n) != n) + if (write_in_full(proc.in, buf, n) < 0) break; } close(proc.in); diff --git a/builtin/rerere.c b/builtin/rerere.c index ffb66e2907..0bc40298c2 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -18,7 +18,7 @@ static int outf(void *dummy, mmbuffer_t *ptr, int nbuf) { int i; for (i = 0; i < nbuf; i++) - if (write_in_full(1, ptr[i].ptr, ptr[i].size) != ptr[i].size) + if (write_in_full(1, ptr[i].ptr, ptr[i].size) < 0) return -1; return 0; } diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index 73f1334191..672a54fcdf 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -15,7 +15,7 @@ static char *create_temp_file(unsigned char *sha1) xsnprintf(path, sizeof(path), ".merge_file_XXXXXX"); fd = xmkstemp(path); - if (write_in_full(fd, buf, size) != size) + if (write_in_full(fd, buf, size) < 0) die_errno("unable to write temp-file"); close(fd); return path; |