From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MLxrY-0007UJ-8c for qemu-devel@nongnu.org; Wed, 01 Jul 2009 07:20:28 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MLxrS-0007SU-A0 for qemu-devel@nongnu.org; Wed, 01 Jul 2009 07:20:26 -0400 Received: from [199.232.76.173] (port=56874 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MLxrR-0007SF-Bn for qemu-devel@nongnu.org; Wed, 01 Jul 2009 07:20:21 -0400 Received: from verein.lst.de ([213.95.11.210]:36017) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1MLxrQ-0005eq-QN for qemu-devel@nongnu.org; Wed, 01 Jul 2009 07:20:21 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id n61BKIbW010491 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 1 Jul 2009 13:20:19 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id n61BKIQT010489 for qemu-devel@nongnu.org; Wed, 1 Jul 2009 13:20:18 +0200 Date: Wed, 1 Jul 2009 13:20:18 +0200 From: Christoph Hellwig Message-ID: <20090701112018.GA10455@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH 1/2] qemu-io: small cleanups for the aio code List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Address a couple of review comments from Kevin. Signed-off-by: Christoph Hellwig Index: qemu/qemu-io.c =================================================================== --- qemu.orig/qemu-io.c 2009-07-01 10:45:24.488370800 +0200 +++ qemu/qemu-io.c 2009-07-01 10:52:44.962241654 +0200 @@ -769,25 +769,23 @@ aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; - int total; - int cnt = 1; gettimeofday(&t2, NULL); - total = ctx->qiov.size; if (ret < 0) { printf("aio_write failed: %s\n", strerror(-ret)); return; } - if (ctx->qflag) + if (ctx->qflag) { return; + } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); - print_report("wrote", &t2, ctx->offset, ctx->qiov.size, total, cnt, - ctx->Cflag); + print_report("wrote", &t2, ctx->offset, ctx->qiov.size, + ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); @@ -800,44 +798,41 @@ aio_read_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; - int total; - int cnt = 1; gettimeofday(&t2, NULL); - total = ctx->qiov.size; - if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); return; } if (ctx->Pflag) { - void *cmp_buf = malloc(total); + void *cmp_buf = malloc(ctx->qiov.size); - memset(cmp_buf, ctx->pattern, total); - if (memcmp(ctx->buf, cmp_buf, total)) { + memset(cmp_buf, ctx->pattern, ctx->qiov.size); + if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { printf("Pattern verification failed at offset %lld, " "%d bytes\n", - (long long) ctx->offset, total); + (long long) ctx->offset, ctx->qiov.size); } free(cmp_buf); } - if (ctx->qflag) + if (ctx->qflag) { return; + } - if (ctx->vflag) - dump_buffer(ctx->buf, ctx->offset, total); + if (ctx->vflag) { + dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size); + } /* Finally, report back -- -C gives a parsable format */ t2 = tsub(t2, ctx->t1); - print_report("read", &t2, ctx->offset, ctx->qiov.size, total, cnt, - ctx->Cflag); + print_report("read", &t2, ctx->offset, ctx->qiov.size, + ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); - } static void @@ -870,8 +865,6 @@ aio_read_f(int argc, char **argv) struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx)); BlockDriverAIOCB *acb; - ctx->pattern = 0xcd; - while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': @@ -1035,7 +1028,6 @@ aio_write_f(int argc, char **argv) return 0; } - for (i = optind; i < argc; i++) { size_t len;