]> git.ipfire.org Git - thirdparty/git.git/blobdiff - pkt-line.c
Fix an "implicit function definition" warning.
[thirdparty/git.git] / pkt-line.c
index bb3bab05cd203e114b24b778cb5f55218abdec95..b4cb7e2756dcc52c17aebf4c0fc6adc7b415ef3c 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 = xwrite(fd, buf, n);
                if (ret > 0) {
-                       buf += ret;
+                       buf = (char *) buf + ret;
                        n -= ret;
                        continue;
                }
@@ -29,6 +30,7 @@ static void safe_write(int fd, const void *buf, unsigned n)
                        die("write error (disk full?)");
                die("write error (%s)", strerror(errno));
        }
+       return nn;
 }
 
 /*
@@ -66,11 +68,11 @@ static void safe_read(int fd, void *buffer, unsigned size)
        int n = 0;
 
        while (n < size) {
-               int ret = xread(fd, buffer + n, size - n);
+               int 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;
        }
 }