]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
safe_io: fix signed/unsigned comparisons
authorSage Weil <sage.weil@dreamhost.com>
Wed, 2 Mar 2011 13:29:01 +0000 (05:29 -0800)
committerSage Weil <sage.weil@dreamhost.com>
Sun, 6 Mar 2011 04:40:13 +0000 (20:40 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/common/safe_io.c

index 325f2c3b952ff8aa2c6e0b357a111d6555217c86..8ad05a3687efd9e19a0bbc4ec979ee3fc501a4a7 100644 (file)
@@ -22,7 +22,7 @@
 ssize_t safe_read(int fd, void *buf, size_t count)
 {
        int r;
-       int cnt = 0;
+       size_t cnt = 0;
 
        while (cnt < count) {
                r = read(fd, buf, count - cnt);
@@ -46,7 +46,7 @@ ssize_t safe_read_exact(int fd, void *buf, size_t count)
        int ret = safe_read(fd, buf, count);
        if (ret < 0)
                return ret;
-       if (ret != count)
+       if ((size_t)ret != count)
                return -EDOM;
        return 0;
 }
@@ -71,7 +71,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;
-       int cnt = 0;
+       size_t cnt = 0;
        char *b = (char*)buf;
 
        while (cnt < count) {
@@ -96,7 +96,7 @@ ssize_t safe_pread_exact(int fd, void *buf, size_t count, off_t offset)
        int ret = safe_pread(fd, buf, count, offset);
        if (ret < 0)
                return ret;
-       if (ret != count)
+       if ((size_t)ret != count)
                return -EDOM;
        return 0;
 }