]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pkt-line.c
Makefile: Remove git-fsck and git-verify-pack from PROGRAMS
[thirdparty/git.git] / pkt-line.c
index 69473046bf717c9b97470d7652c15377dd9fc9d5..b60526869a38bd20f800c275f7b42390c8bea1ee 100644 (file)
  * The writing side could use stdio, but since the reading
  * side can't, we stay with pure read/write interfaces.
  */
-static void safe_write(int fd, const void *buf, unsigned n)
+ssize_t safe_write(int fd, const void *buf, ssize_t n)
 {
+       ssize_t nn = n;
        while (n) {
-               int ret = write(fd, buf, n);
+               int ret = xwrite(fd, buf, n);
                if (ret > 0) {
-                       buf += ret;
+                       buf = (char *) buf + ret;
                        n -= ret;
                        continue;
                }
                if (!ret)
                        die("write error (disk full?)");
-               if (errno == EAGAIN || errno == EINTR)
-                       continue;
                die("write error (%s)", strerror(errno));
        }
+       return nn;
 }
 
 /*
@@ -65,17 +65,14 @@ void packet_write(int fd, const char *fmt, ...)
 
 static void safe_read(int fd, void *buffer, unsigned size)
 {
-       int n = 0;
+       size_t n = 0;
 
        while (n < size) {
-               int ret = read(fd, buffer + n, size - n);
-               if (ret < 0) {
-                       if (errno == EINTR || errno == EAGAIN)
-                               continue;
+               ssize_t ret = xread(fd, (char *) buffer + n, size - n);
+               if (ret < 0)
                        die("read error (%s)", strerror(errno));
-               }
                if (!ret)
-                       die("unexpected EOF");
+                       die("The remote end hung up unexpectedly");
                n += ret;
        }
 }