@matheusbsbs / matheus-bagliano / commits / 23bc886c96
Fork 0

Replace ywrite in fast-import with the standard write_or_die.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Aug 28, 2006 at 13:54 UTC 23bc886c966b4362555b61f33c6eef71552e4d0e
1 file changed +7 -20
fast-import.c
+7 -20
@@ -586,19 +586,6 @@ static void yread(int fd, void *buffer, size_t length)
586 }
587 }
588
589 -static void ywrite(int fd, void *buffer, size_t length)
590 -{
591 - ssize_t ret = 0;
592 - while (ret < length) {
593 - ssize_t size = xwrite(fd, (char *) buffer + ret, length - ret);
594 - if (!size)
595 - die("Write to descriptor %i: end of file", fd);
596 - if (size < 0)
597 - die("Write to descriptor %i: %s", fd, strerror(errno));
598 - ret += size;
599 - }
600 -}
601 -
589 static size_t encode_header(
590 enum object_type type,
591 size_t size,
@@ -675,8 +662,8 @@ static int store_object(
662 s.next_in = delta;
663 s.avail_in = deltalen;
664 hdrlen = encode_header(OBJ_DELTA, deltalen, hdr);
678 - ywrite(pack_fd, hdr, hdrlen);
679 - ywrite(pack_fd, last->sha1, sizeof(sha1));
665 + write_or_die(pack_fd, hdr, hdrlen);
666 + write_or_die(pack_fd, last->sha1, sizeof(sha1));
667 pack_size += hdrlen + sizeof(sha1);
668 } else {
669 if (last)
@@ -684,7 +671,7 @@ static int store_object(
671 s.next_in = dat;
672 s.avail_in = datlen;
673 hdrlen = encode_header(type, datlen, hdr);
687 - ywrite(pack_fd, hdr, hdrlen);
674 + write_or_die(pack_fd, hdr, hdrlen);
675 pack_size += hdrlen;
676 }
677
@@ -694,7 +681,7 @@ static int store_object(
681 /* nothing */;
682 deflateEnd(&s);
683
697 - ywrite(pack_fd, out, s.total_out);
684 + write_or_die(pack_fd, out, s.total_out);
685 pack_size += s.total_out;
686
687 free(out);
@@ -1117,7 +1104,7 @@ static void init_pack_header()
1104 hdr.hdr_version = htonl(2);
1105 hdr.hdr_entries = 0;
1106
1120 - ywrite(pack_fd, &hdr, sizeof(hdr));
1107 + write_or_die(pack_fd, &hdr, sizeof(hdr));
1108 pack_size = sizeof(hdr);
1109 }
1110
@@ -1138,7 +1125,7 @@ static void fixup_header_footer()
1125
1126 cnt = htonl(object_count);
1127 SHA1_Update(&c, &cnt, 4);
1141 - ywrite(pack_fd, &cnt, 4);
1128 + write_or_die(pack_fd, &cnt, 4);
1129
1130 buf = xmalloc(128 * 1024);
1131 for (;;) {
@@ -1150,7 +1137,7 @@ static void fixup_header_footer()
1137 free(buf);
1138
1139 SHA1_Final(pack_sha1, &c);
1153 - ywrite(pack_fd, pack_sha1, sizeof(pack_sha1));
1140 + write_or_die(pack_fd, pack_sha1, sizeof(pack_sha1));
1141 }
1142
1143 static int oecmp (const void *_a, const void *_b)