X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fcopy.c;h=b8b1ba18664da6d615a5e98e831dbd505211adb4;hb=553acb7b6b8d4f16a4747b1f978e8b7888fbfb2c;hp=a863246b2bf47c5ed821f2603f8ddb9f0ea3c38a;hpb=cda134ab1eac84f874aacf8e885a07112a7fd5ce;p=elogind.git diff --git a/src/shared/copy.c b/src/shared/copy.c index a863246b2..b8b1ba186 100644 --- a/src/shared/copy.c +++ b/src/shared/copy.c @@ -37,7 +37,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes) { if (max_bytes != (off_t) -1) { if (max_bytes <= 0) - return -E2BIG; + return -EFBIG; if ((off_t) m > max_bytes) m = (size_t) max_bytes; @@ -63,7 +63,7 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes) { /* As a fallback just copy bits by hand */ { char buf[m]; - ssize_t k; + int r; n = read(fdf, buf, m); if (n < 0) @@ -71,12 +71,9 @@ int copy_bytes(int fdf, int fdt, off_t max_bytes) { if (n == 0) /* EOF */ break; - errno = 0; - k = loop_write(fdt, buf, n, false); - if (k < 0) - return k; - if (k != n) - return errno ? -errno : -EIO; + r = loop_write(fdt, buf, n, false); + if (r < 0) + return r; }