From: Danny Al-Gaaf Date: Tue, 7 May 2013 15:25:26 +0000 (+0200) Subject: common/safe_io.c: reduce scope of some ssize_t variables X-Git-Tag: v0.63~46^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e064e67c2b2379f4f449d2459e89c90200a4d2ea;p=ceph.git common/safe_io.c: reduce scope of some ssize_t variables Signed-off-by: Danny Al-Gaaf --- diff --git a/src/common/safe_io.c b/src/common/safe_io.c index a7be648ebf41..ac99db04ad3e 100644 --- a/src/common/safe_io.c +++ b/src/common/safe_io.c @@ -21,11 +21,10 @@ ssize_t safe_read(int fd, void *buf, size_t count) { - ssize_t r; size_t cnt = 0; while (cnt < count) { - r = read(fd, buf, count - cnt); + ssize_t r = read(fd, buf, count - cnt); if (r <= 0) { if (r == 0) { // EOF @@ -53,10 +52,8 @@ ssize_t safe_read_exact(int fd, void *buf, size_t count) ssize_t safe_write(int fd, const void *buf, size_t count) { - ssize_t r; - while (count > 0) { - r = write(fd, buf, count); + ssize_t r = write(fd, buf, count); if (r < 0) { if (errno == EINTR) continue; @@ -70,12 +67,11 @@ 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) { - ssize_t r; size_t cnt = 0; char *b = (char*)buf; while (cnt < count) { - r = pread(fd, b + cnt, count - cnt, offset + cnt); + ssize_t r = pread(fd, b + cnt, count - cnt, offset + cnt); if (r <= 0) { if (r == 0) { // EOF @@ -103,10 +99,8 @@ 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) { - ssize_t r; - while (count > 0) { - r = pwrite(fd, buf, count, offset); + ssize_t r = pwrite(fd, buf, count, offset); if (r < 0) { if (errno == EINTR) continue;