From 1ca56f4c1603944feb150aa137357a3d1464da79 Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Mon, 4 May 2015 20:02:55 +0200 Subject: [PATCH] test/librbd/fsx.cc: reduce scope of variables Signed-off-by: Danny Al-Gaaf (cherry picked from commit af144371f0a168494d848359390e8b5306b7a380) --- src/test/librbd/fsx.cc | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 2465417fccdc8..dba7e9ea75f99 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -627,8 +627,6 @@ krbd_write(struct rbd_ctx *ctx, uint64_t off, size_t len, const char *buf) int __krbd_flush(struct rbd_ctx *ctx) { - int ret; - if (o_direct) return 0; @@ -638,7 +636,7 @@ __krbd_flush(struct rbd_ctx *ctx) * lifetime of the block device and write directly to it. */ if (fsync(ctx->krbd_fd) < 0) { - ret = -errno; + int ret = -errno; prt("fsync failed\n"); return ret; } @@ -676,10 +674,9 @@ int krbd_get_size(struct rbd_ctx *ctx, uint64_t *size) { uint64_t bytes; - int ret; if (ioctl(ctx->krbd_fd, BLKGETSIZE64, &bytes) < 0) { - ret = -errno; + int ret = -errno; prt("BLKGETSIZE64 failed\n"); return ret; } @@ -950,25 +947,22 @@ report_failure(int status) void check_buffers(char *good_buf, char *temp_buf, unsigned offset, unsigned size) { - unsigned char c, t; - unsigned i = 0; - unsigned n = 0; - unsigned op = 0; - unsigned bad = 0; - if (memcmp(good_buf + offset, temp_buf, size) != 0) { + unsigned i = 0; + unsigned n = 0; + prt("READ BAD DATA: offset = 0x%x, size = 0x%x, fname = %s\n", offset, size, iname); prt("OFFSET\tGOOD\tBAD\tRANGE\n"); while (size > 0) { - c = good_buf[offset]; - t = temp_buf[i]; + unsigned char c = good_buf[offset]; + unsigned char t = temp_buf[i]; if (c != t) { if (n < 16) { - bad = short_at(&temp_buf[i]); + unsigned bad = short_at(&temp_buf[i]); prt("0x%5x\t0x%04x\t0x%04x", offset, short_at(&good_buf[offset]), bad); - op = temp_buf[offset & 1 ? i+1 : i]; + unsigned op = temp_buf[offset & 1 ? i+1 : i]; prt("\t0x%5x\n", n); if (op) prt("operation# (mod 256) for "