summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorHeikki Orsila <heikki.orsila@iki.fi>2008-05-03 13:27:26 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-05-04 05:15:25 (GMT)
commitc697ad143ba1ff58b29e7efe149d244d4b7010a5 (patch)
tree7d3446a01ad6e3f37dd318e0e29d57da21024366 /combine-diff.c
parent471793f91e4bd61bb809045c7088a30ee1305a19 (diff)
downloadgit-c697ad143ba1ff58b29e7efe149d244d4b7010a5.zip
git-c697ad143ba1ff58b29e7efe149d244d4b7010a5.tar.gz
git-c697ad143ba1ff58b29e7efe149d244d4b7010a5.tar.bz2
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 'combine-diff.c')
-rw-r--r--combine-diff.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 41aaf83..588c58b 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -701,7 +701,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
!fstat(fd, &st)) {
size_t len = xsize_t(st.st_size);
- size_t sz = 0;
+ ssize_t done;
int is_file, i;
elem->mode = canon_mode(st.st_mode);
@@ -716,14 +716,13 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
result_size = len;
result = xmalloc(len + 1);
- while (sz < len) {
- ssize_t done = xread(fd, result+sz, len-sz);
- if (done == 0 && sz != len)
- die("early EOF '%s'", elem->path);
- else if (done < 0)
- die("read error '%s'", elem->path);
- sz += done;
- }
+
+ done = read_in_full(fd, result, len);
+ if (done < 0)
+ die("read error '%s'", elem->path);
+ else if (done < len)
+ die("early EOF '%s'", elem->path);
+
result[len] = 0;
}
else {