diff options
author | Heikki Orsila <heikki.orsila@iki.fi> | 2008-05-03 16:27:26 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-05-03 22:15:25 -0700 |
commit | c697ad143ba1ff58b29e7efe149d244d4b7010a5 (patch) | |
tree | 7d3446a01ad6e3f37dd318e0e29d57da21024366 /pkt-line.c | |
parent | 471793f91e4bd61bb809045c7088a30ee1305a19 (diff) | |
download | git-c697ad143ba1ff58b29e7efe149d244d4b7010a5.tar.gz |
Cleanup xread() loops to use read_in_full()
Signed-off-by: Heikki Orsila <heikki.orsila@iki.fi>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pkt-line.c')
-rw-r--r-- | pkt-line.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/pkt-line.c b/pkt-line.c index 355546a1ad..f5d00863a6 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -65,16 +65,11 @@ void packet_write(int fd, const char *fmt, ...) static void safe_read(int fd, void *buffer, unsigned size) { - size_t n = 0; - - while (n < size) { - ssize_t ret = xread(fd, (char *) buffer + n, size - n); - if (ret < 0) - die("read error (%s)", strerror(errno)); - if (!ret) - die("The remote end hung up unexpectedly"); - n += ret; - } + ssize_t ret = read_in_full(fd, buffer, size); + if (ret < 0) + die("read error (%s)", strerror(errno)); + else if (ret < size) + die("The remote end hung up unexpectedly"); } int packet_read_line(int fd, char *buffer, unsigned size) |