commit 38c670f14feb46a50c367924ad72f88dddfbad01 from: Stefan Sperling date: Wed Mar 18 16:11:31 2020 UTC convert flushpkt to struct got_error commit - 344e474767f52e48fa8b238638b9507b2002f4d4 commit + 38c670f14feb46a50c367924ad72f88dddfbad01 blob - 7dba862a0feb7f94085895c18ed8b65612694135 blob + e593a8ed5db8f3e51ad09cbd00486332aef60259 --- libexec/got-fetch-pack/got-fetch-pack.c +++ libexec/got-fetch-pack/got-fetch-pack.c @@ -75,12 +75,20 @@ readn(ssize_t *off, int fd, void *buf, size_t n) return NULL; } -static int +static const struct got_error * flushpkt(int fd) { + ssize_t w; + if (chattygit) fprintf(stderr, "writepkt: 0000\n"); - return write(fd, "0000", 4); + + w = write(fd, "0000", 4); + if (w == -1) + return got_error_from_errno("write"); + if (w != 4) + return got_error(GOT_ERR_IO); + return NULL; } @@ -528,7 +536,9 @@ fetch_pack(int fd, int packfd, struct got_object_id *p goto done; req = 1; } - flushpkt(fd); + err = flushpkt(fd); + if (err) + goto done; for (i = 0; i < nref; i++) { if (got_object_id_cmp(&have[i], &zhash) == 0) continue; @@ -544,7 +554,9 @@ fetch_pack(int fd, int packfd, struct got_object_id *p } if (!req) { fprintf(stderr, "up to date\n"); - flushpkt(fd); + err = flushpkt(fd); + if (err) + goto done; } n = snprintf(buf, sizeof(buf), "done\n"); err = writepkt(fd, buf, n);