summaryrefslogtreecommitdiff
path: root/sha1_file.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 /sha1_file.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 'sha1_file.c')
-rw-r--r--sha1_file.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/sha1_file.c b/sha1_file.c
index c2ab7ea..3516777 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2466,16 +2466,10 @@ int index_path(unsigned char *sha1, const char *path, struct stat *st, int write
int read_pack_header(int fd, struct pack_header *header)
{
- char *c = (char*)header;
- ssize_t remaining = sizeof(struct pack_header);
- do {
- ssize_t r = xread(fd, c, remaining);
- if (r <= 0)
- /* "eof before pack header was fully read" */
- return PH_ERROR_EOF;
- remaining -= r;
- c += r;
- } while (remaining > 0);
+ if (read_in_full(fd, header, sizeof(*header)) < sizeof(*header))
+ /* "eof before pack header was fully read" */
+ return PH_ERROR_EOF;
+
if (header->hdr_signature != htonl(PACK_SIGNATURE))
/* "protocol error (pack signature mismatch detected)" */
return PH_ERROR_PACK_SIGNATURE;