]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
safe_io: int -> ssize_t
authorSage Weil <sage@inktank.com>
Sat, 5 May 2012 17:01:44 +0000 (10:01 -0700)
committerSage Weil <sage@inktank.com>
Sat, 5 May 2012 17:01:44 +0000 (10:01 -0700)
int is 32-bit on 64-bit archs, but ssize_t is 64-bits.  This fixes overflow
when reading large (>2GB) extends.

Fixes: #2275
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/common/safe_io.c

index 8ad05a3687efd9e19a0bbc4ec979ee3fc501a4a7..a7be648ebf41e5cf9a69907c53a068e2615bc2dc 100644 (file)
@@ -21,7 +21,7 @@
 
 ssize_t safe_read(int fd, void *buf, size_t count)
 {
-       int r;
+       ssize_t r;
        size_t cnt = 0;
 
        while (cnt < count) {
@@ -43,7 +43,7 @@ ssize_t safe_read(int fd, void *buf, size_t count)
 
 ssize_t safe_read_exact(int fd, void *buf, size_t count)
 {
-       int ret = safe_read(fd, buf, count);
+        ssize_t ret = safe_read(fd, buf, count);
        if (ret < 0)
                return ret;
        if ((size_t)ret != count)
@@ -53,7 +53,7 @@ ssize_t safe_read_exact(int fd, void *buf, size_t count)
  
 ssize_t safe_write(int fd, const void *buf, size_t count)
 {
-       int r;
+       ssize_t r;
 
        while (count > 0) {
                r = write(fd, buf, count);
@@ -70,7 +70,7 @@ ssize_t safe_write(int fd, const void *buf, size_t count)
 
 ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset)
 {
-       int r;
+       ssize_t r;
        size_t cnt = 0;
        char *b = (char*)buf;
 
@@ -93,7 +93,7 @@ ssize_t safe_pread(int fd, void *buf, size_t count, off_t offset)
 
 ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset)
 {
-       int ret = safe_pread(fd, buf, count, offset);
+       ssize_t ret = safe_pread(fd, buf, count, offset);
        if (ret < 0)
                return ret;
        if ((size_t)ret != count)
@@ -103,7 +103,7 @@ ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset)
 
 ssize_t safe_pwrite(int fd, const void *buf, size_t count, off_t offset)
 {
-       int r;
+       ssize_t r;
 
        while (count > 0) {
                r = pwrite(fd, buf, count, offset);