26ba25
From fed57d13b5e402e6d385189acb78aa5f84343fe4 Mon Sep 17 00:00:00 2001
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
Date: Mon, 25 Jun 2018 13:09:51 +0200
26ba25
Subject: [PATCH 049/268] qemu-io: Drop command functions' return values
26ba25
26ba25
RH-Author: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: <20180618164312.24423-2-mreitz@redhat.com>
26ba25
Patchwork-id: 80778
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/5] qemu-io: Drop command functions' return values
26ba25
Bugzilla: 1519617
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
26ba25
For qemu-io, a function returns an integer with two possible values: 0
26ba25
for "qemu-io may continue execution", or 1 for "qemu-io should exit".
26ba25
However, there is only a single command that returns 1, and that is
26ba25
"quit".
26ba25
26ba25
So let's turn this case into a global variable instead so we can make
26ba25
better use of the return value in a later patch.
26ba25
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Message-id: 20180509194302.21585-2-mreitz@redhat.com
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
(cherry picked from commit b444d0e9d1ae323fed1ef7c35a359ce064f36b32)
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 include/qemu-io.h |   6 +-
26ba25
 qemu-io-cmds.c    | 294 +++++++++++++++++++++++++-----------------------------
26ba25
 qemu-io.c         |  36 +++----
26ba25
 3 files changed, 157 insertions(+), 179 deletions(-)
26ba25
26ba25
diff --git a/include/qemu-io.h b/include/qemu-io.h
26ba25
index 196fde0..06cdfbf 100644
26ba25
--- a/include/qemu-io.h
26ba25
+++ b/include/qemu-io.h
26ba25
@@ -22,7 +22,7 @@
26ba25
 
26ba25
 #define CMD_FLAG_GLOBAL ((int)0x80000000) /* don't iterate "args" */
26ba25
 
26ba25
-typedef int (*cfunc_t)(BlockBackend *blk, int argc, char **argv);
26ba25
+typedef void (*cfunc_t)(BlockBackend *blk, int argc, char **argv);
26ba25
 typedef void (*helpfunc_t)(void);
26ba25
 
26ba25
 typedef struct cmdinfo {
26ba25
@@ -41,10 +41,10 @@ typedef struct cmdinfo {
26ba25
 
26ba25
 extern bool qemuio_misalign;
26ba25
 
26ba25
-bool qemuio_command(BlockBackend *blk, const char *cmd);
26ba25
+void qemuio_command(BlockBackend *blk, const char *cmd);
26ba25
 
26ba25
 void qemuio_add_command(const cmdinfo_t *ci);
26ba25
-int qemuio_command_usage(const cmdinfo_t *ci);
26ba25
+void qemuio_command_usage(const cmdinfo_t *ci);
26ba25
 void qemuio_complete_command(const char *input,
26ba25
                              void (*fn)(const char *cmd, void *opaque),
26ba25
                              void *opaque);
26ba25
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
26ba25
index 9b3cd00..c2fbaae 100644
26ba25
--- a/qemu-io-cmds.c
26ba25
+++ b/qemu-io-cmds.c
26ba25
@@ -48,10 +48,9 @@ void qemuio_add_command(const cmdinfo_t *ci)
26ba25
     qsort(cmdtab, ncmds, sizeof(*cmdtab), compare_cmdname);
26ba25
 }
26ba25
 
26ba25
-int qemuio_command_usage(const cmdinfo_t *ci)
26ba25
+void qemuio_command_usage(const cmdinfo_t *ci)
26ba25
 {
26ba25
     printf("%s %s -- %s\n", ci->name, ci->args, ci->oneline);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static int init_check_command(BlockBackend *blk, const cmdinfo_t *ct)
26ba25
@@ -66,13 +65,13 @@ static int init_check_command(BlockBackend *blk, const cmdinfo_t *ct)
26ba25
     return 1;
26ba25
 }
26ba25
 
26ba25
-static int command(BlockBackend *blk, const cmdinfo_t *ct, int argc,
26ba25
-                   char **argv)
26ba25
+static void command(BlockBackend *blk, const cmdinfo_t *ct, int argc,
26ba25
+                    char **argv)
26ba25
 {
26ba25
     char *cmd = argv[0];
26ba25
 
26ba25
     if (!init_check_command(blk, ct)) {
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (argc - 1 < ct->argmin || (ct->argmax != -1 && argc - 1 > ct->argmax)) {
26ba25
@@ -89,7 +88,7 @@ static int command(BlockBackend *blk, const cmdinfo_t *ct, int argc,
26ba25
                     "bad argument count %d to %s, expected between %d and %d arguments\n",
26ba25
                     argc-1, cmd, ct->argmin, ct->argmax);
26ba25
         }
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     /* Request additional permissions if necessary for this command. The caller
26ba25
@@ -109,13 +108,13 @@ static int command(BlockBackend *blk, const cmdinfo_t *ct, int argc,
26ba25
             ret = blk_set_perm(blk, new_perm, orig_shared_perm, &local_err);
26ba25
             if (ret < 0) {
26ba25
                 error_report_err(local_err);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     optind = 0;
26ba25
-    return ct->cfunc(blk, argc, argv);
26ba25
+    ct->cfunc(blk, argc, argv);
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t *find_command(const char *cmd)
26ba25
@@ -634,7 +633,7 @@ static void read_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int read_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void read_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t read_cmd = {
26ba25
     .name       = "read",
26ba25
@@ -647,7 +646,7 @@ static const cmdinfo_t read_cmd = {
26ba25
     .help       = read_help,
26ba25
 };
26ba25
 
26ba25
-static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void read_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     struct timeval t1, t2;
26ba25
     bool Cflag = false, qflag = false, vflag = false;
26ba25
@@ -674,7 +673,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
             pattern_count = cvtnum(optarg);
26ba25
             if (pattern_count < 0) {
26ba25
                 print_cvtnum_err(pattern_count, optarg);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'p':
26ba25
@@ -684,7 +683,7 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
             Pflag = true;
26ba25
             pattern = parse_pattern(optarg);
26ba25
             if (pattern < 0) {
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'q':
26ba25
@@ -695,40 +694,43 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
             pattern_offset = cvtnum(optarg);
26ba25
             if (pattern_offset < 0) {
26ba25
                 print_cvtnum_err(pattern_offset, optarg);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'v':
26ba25
             vflag = true;
26ba25
             break;
26ba25
         default:
26ba25
-            return qemuio_command_usage(&read_cmd);
26ba25
+            qemuio_command_usage(&read_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind != argc - 2) {
26ba25
-        return qemuio_command_usage(&read_cmd);
26ba25
+        qemuio_command_usage(&read_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     offset = cvtnum(argv[optind]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     optind++;
26ba25
     count = cvtnum(argv[optind]);
26ba25
     if (count < 0) {
26ba25
         print_cvtnum_err(count, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     } else if (count > BDRV_REQUEST_MAX_BYTES) {
26ba25
         printf("length cannot exceed %" PRIu64 ", given %s\n",
26ba25
                (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (!Pflag && (lflag || sflag)) {
26ba25
-        return qemuio_command_usage(&read_cmd);
26ba25
+        qemuio_command_usage(&read_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (!lflag) {
26ba25
@@ -737,19 +739,19 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
 
26ba25
     if ((pattern_count < 0) || (pattern_count + pattern_offset > count))  {
26ba25
         printf("pattern verification range exceeds end of read data\n");
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (bflag) {
26ba25
         if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
26ba25
             printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
26ba25
                    offset);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
         if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
26ba25
             printf("%"PRId64" is not a sector-aligned value for 'count'\n",
26ba25
                    count);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
@@ -793,8 +795,6 @@ static int read_f(BlockBackend *blk, int argc, char **argv)
26ba25
 
26ba25
 out:
26ba25
     qemu_io_free(buf);
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static void readv_help(void)
26ba25
@@ -816,7 +816,7 @@ static void readv_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int readv_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void readv_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t readv_cmd = {
26ba25
     .name       = "readv",
26ba25
@@ -828,7 +828,7 @@ static const cmdinfo_t readv_cmd = {
26ba25
     .help       = readv_help,
26ba25
 };
26ba25
 
26ba25
-static int readv_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void readv_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     struct timeval t1, t2;
26ba25
     bool Cflag = false, qflag = false, vflag = false;
26ba25
@@ -851,7 +851,7 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
26ba25
             Pflag = true;
26ba25
             pattern = parse_pattern(optarg);
26ba25
             if (pattern < 0) {
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'q':
26ba25
@@ -861,26 +861,28 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
26ba25
             vflag = true;
26ba25
             break;
26ba25
         default:
26ba25
-            return qemuio_command_usage(&readv_cmd);
26ba25
+            qemuio_command_usage(&readv_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind > argc - 2) {
26ba25
-        return qemuio_command_usage(&readv_cmd);
26ba25
+        qemuio_command_usage(&readv_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
 
26ba25
     offset = cvtnum(argv[optind]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
     optind++;
26ba25
 
26ba25
     nr_iov = argc - optind;
26ba25
     buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, 0xab);
26ba25
     if (buf == NULL) {
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     gettimeofday(&t1, NULL);
26ba25
@@ -917,7 +919,6 @@ static int readv_f(BlockBackend *blk, int argc, char **argv)
26ba25
 out:
26ba25
     qemu_iovec_destroy(&qiov);
26ba25
     qemu_io_free(buf);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static void write_help(void)
26ba25
@@ -943,7 +944,7 @@ static void write_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int write_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void write_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t write_cmd = {
26ba25
     .name       = "write",
26ba25
@@ -957,7 +958,7 @@ static const cmdinfo_t write_cmd = {
26ba25
     .help       = write_help,
26ba25
 };
26ba25
 
26ba25
-static int write_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void write_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     struct timeval t1, t2;
26ba25
     bool Cflag = false, qflag = false, bflag = false;
26ba25
@@ -992,7 +993,7 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
26ba25
             Pflag = true;
26ba25
             pattern = parse_pattern(optarg);
26ba25
             if (pattern < 0) {
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'q':
26ba25
@@ -1005,62 +1006,64 @@ static int write_f(BlockBackend *blk, int argc, char **argv)
26ba25
             zflag = true;
26ba25
             break;
26ba25
         default:
26ba25
-            return qemuio_command_usage(&write_cmd);
26ba25
+            qemuio_command_usage(&write_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind != argc - 2) {
26ba25
-        return qemuio_command_usage(&write_cmd);
26ba25
+        qemuio_command_usage(&write_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (bflag && zflag) {
26ba25
         printf("-b and -z cannot be specified at the same time\n");
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if ((flags & BDRV_REQ_FUA) && (bflag || cflag)) {
26ba25
         printf("-f and -b or -c cannot be specified at the same time\n");
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if ((flags & BDRV_REQ_MAY_UNMAP) && !zflag) {
26ba25
         printf("-u requires -z to be specified\n");
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (zflag && Pflag) {
26ba25
         printf("-z and -P cannot be specified at the same time\n");
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     offset = cvtnum(argv[optind]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     optind++;
26ba25
     count = cvtnum(argv[optind]);
26ba25
     if (count < 0) {
26ba25
         print_cvtnum_err(count, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     } else if (count > BDRV_REQUEST_MAX_BYTES) {
26ba25
         printf("length cannot exceed %" PRIu64 ", given %s\n",
26ba25
                (uint64_t)BDRV_REQUEST_MAX_BYTES, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (bflag || cflag) {
26ba25
         if (!QEMU_IS_ALIGNED(offset, BDRV_SECTOR_SIZE)) {
26ba25
             printf("%" PRId64 " is not a sector-aligned value for 'offset'\n",
26ba25
                    offset);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
 
26ba25
         if (!QEMU_IS_ALIGNED(count, BDRV_SECTOR_SIZE)) {
26ba25
             printf("%"PRId64" is not a sector-aligned value for 'count'\n",
26ba25
                    count);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
@@ -1097,8 +1100,6 @@ out:
26ba25
     if (!zflag) {
26ba25
         qemu_io_free(buf);
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static void
26ba25
@@ -1120,7 +1121,7 @@ writev_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int writev_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void writev_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t writev_cmd = {
26ba25
     .name       = "writev",
26ba25
@@ -1133,7 +1134,7 @@ static const cmdinfo_t writev_cmd = {
26ba25
     .help       = writev_help,
26ba25
 };
26ba25
 
26ba25
-static int writev_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void writev_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     struct timeval t1, t2;
26ba25
     bool Cflag = false, qflag = false;
26ba25
@@ -1161,29 +1162,31 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)
26ba25
         case 'P':
26ba25
             pattern = parse_pattern(optarg);
26ba25
             if (pattern < 0) {
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         default:
26ba25
-            return qemuio_command_usage(&writev_cmd);
26ba25
+            qemuio_command_usage(&writev_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind > argc - 2) {
26ba25
-        return qemuio_command_usage(&writev_cmd);
26ba25
+        qemuio_command_usage(&writev_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     offset = cvtnum(argv[optind]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
     optind++;
26ba25
 
26ba25
     nr_iov = argc - optind;
26ba25
     buf = create_iovec(blk, &qiov, &argv[optind], nr_iov, pattern);
26ba25
     if (buf == NULL) {
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     gettimeofday(&t1, NULL);
26ba25
@@ -1205,7 +1208,6 @@ static int writev_f(BlockBackend *blk, int argc, char **argv)
26ba25
 out:
26ba25
     qemu_iovec_destroy(&qiov);
26ba25
     qemu_io_free(buf);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 struct aio_ctx {
26ba25
@@ -1320,7 +1322,7 @@ static void aio_read_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int aio_read_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void aio_read_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t aio_read_cmd = {
26ba25
     .name       = "aio_read",
26ba25
@@ -1332,7 +1334,7 @@ static const cmdinfo_t aio_read_cmd = {
26ba25
     .help       = aio_read_help,
26ba25
 };
26ba25
 
26ba25
-static int aio_read_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void aio_read_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int nr_iov, c;
26ba25
     struct aio_ctx *ctx = g_new0(struct aio_ctx, 1);
26ba25
@@ -1348,14 +1350,14 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)
26ba25
             ctx->pattern = parse_pattern(optarg);
26ba25
             if (ctx->pattern < 0) {
26ba25
                 g_free(ctx);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'i':
26ba25
             printf("injecting invalid read request\n");
26ba25
             block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_READ);
26ba25
             g_free(ctx);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         case 'q':
26ba25
             ctx->qflag = true;
26ba25
             break;
26ba25
@@ -1364,20 +1366,22 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)
26ba25
             break;
26ba25
         default:
26ba25
             g_free(ctx);
26ba25
-            return qemuio_command_usage(&aio_read_cmd);
26ba25
+            qemuio_command_usage(&aio_read_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind > argc - 2) {
26ba25
         g_free(ctx);
26ba25
-        return qemuio_command_usage(&aio_read_cmd);
26ba25
+        qemuio_command_usage(&aio_read_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     ctx->offset = cvtnum(argv[optind]);
26ba25
     if (ctx->offset < 0) {
26ba25
         print_cvtnum_err(ctx->offset, argv[optind]);
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
     optind++;
26ba25
 
26ba25
@@ -1386,14 +1390,13 @@ static int aio_read_f(BlockBackend *blk, int argc, char **argv)
26ba25
     if (ctx->buf == NULL) {
26ba25
         block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_READ);
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     gettimeofday(&ctx->t1, NULL);
26ba25
     block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size,
26ba25
                      BLOCK_ACCT_READ);
26ba25
     blk_aio_preadv(blk, ctx->offset, &ctx->qiov, 0, aio_read_done, ctx);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static void aio_write_help(void)
26ba25
@@ -1420,7 +1423,7 @@ static void aio_write_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int aio_write_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void aio_write_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t aio_write_cmd = {
26ba25
     .name       = "aio_write",
26ba25
@@ -1433,7 +1436,7 @@ static const cmdinfo_t aio_write_cmd = {
26ba25
     .help       = aio_write_help,
26ba25
 };
26ba25
 
26ba25
-static int aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int nr_iov, c;
26ba25
     int pattern = 0xcd;
26ba25
@@ -1459,51 +1462,53 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
             pattern = parse_pattern(optarg);
26ba25
             if (pattern < 0) {
26ba25
                 g_free(ctx);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'i':
26ba25
             printf("injecting invalid write request\n");
26ba25
             block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);
26ba25
             g_free(ctx);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         case 'z':
26ba25
             ctx->zflag = true;
26ba25
             break;
26ba25
         default:
26ba25
             g_free(ctx);
26ba25
-            return qemuio_command_usage(&aio_write_cmd);
26ba25
+            qemuio_command_usage(&aio_write_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind > argc - 2) {
26ba25
         g_free(ctx);
26ba25
-        return qemuio_command_usage(&aio_write_cmd);
26ba25
+        qemuio_command_usage(&aio_write_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (ctx->zflag && optind != argc - 2) {
26ba25
         printf("-z supports only a single length parameter\n");
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if ((flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) {
26ba25
         printf("-u requires -z to be specified\n");
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (ctx->zflag && ctx->Pflag) {
26ba25
         printf("-z and -P cannot be specified at the same time\n");
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     ctx->offset = cvtnum(argv[optind]);
26ba25
     if (ctx->offset < 0) {
26ba25
         print_cvtnum_err(ctx->offset, argv[optind]);
26ba25
         g_free(ctx);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
     optind++;
26ba25
 
26ba25
@@ -1512,7 +1517,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
         if (count < 0) {
26ba25
             print_cvtnum_err(count, argv[optind]);
26ba25
             g_free(ctx);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
 
26ba25
         ctx->qiov.size = count;
26ba25
@@ -1525,7 +1530,7 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
         if (ctx->buf == NULL) {
26ba25
             block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE);
26ba25
             g_free(ctx);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
 
26ba25
         gettimeofday(&ctx->t1, NULL);
26ba25
@@ -1535,16 +1540,14 @@ static int aio_write_f(BlockBackend *blk, int argc, char **argv)
26ba25
         blk_aio_pwritev(blk, ctx->offset, &ctx->qiov, flags, aio_write_done,
26ba25
                         ctx);
26ba25
     }
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
-static int aio_flush_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void aio_flush_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     BlockAcctCookie cookie;
26ba25
     block_acct_start(blk_get_stats(blk), &cookie, 0, BLOCK_ACCT_FLUSH);
26ba25
     blk_drain_all();
26ba25
     block_acct_done(blk_get_stats(blk), &cookie);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t aio_flush_cmd = {
26ba25
@@ -1553,10 +1556,9 @@ static const cmdinfo_t aio_flush_cmd = {
26ba25
     .oneline    = "completes all outstanding aio requests"
26ba25
 };
26ba25
 
26ba25
-static int flush_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void flush_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     blk_flush(blk);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t flush_cmd = {
26ba25
@@ -1566,7 +1568,7 @@ static const cmdinfo_t flush_cmd = {
26ba25
     .oneline    = "flush all in-core file state to disk",
26ba25
 };
26ba25
 
26ba25
-static int truncate_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void truncate_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     Error *local_err = NULL;
26ba25
     int64_t offset;
26ba25
@@ -1575,16 +1577,14 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv)
26ba25
     offset = cvtnum(argv[1]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     ret = blk_truncate(blk, offset, PREALLOC_MODE_OFF, &local_err);
26ba25
     if (ret < 0) {
26ba25
         error_report_err(local_err);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t truncate_cmd = {
26ba25
@@ -1598,7 +1598,7 @@ static const cmdinfo_t truncate_cmd = {
26ba25
     .oneline    = "truncates the current file at the given offset",
26ba25
 };
26ba25
 
26ba25
-static int length_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void length_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int64_t size;
26ba25
     char s1[64];
26ba25
@@ -1606,12 +1606,11 @@ static int length_f(BlockBackend *blk, int argc, char **argv)
26ba25
     size = blk_getlength(blk);
26ba25
     if (size < 0) {
26ba25
         printf("getlength: %s\n", strerror(-size));
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     cvtstr(size, s1, sizeof(s1));
26ba25
     printf("%s\n", s1);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 
26ba25
@@ -1623,7 +1622,7 @@ static const cmdinfo_t length_cmd = {
26ba25
 };
26ba25
 
26ba25
 
26ba25
-static int info_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void info_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     BlockDriverState *bs = blk_bs(blk);
26ba25
     BlockDriverInfo bdi;
26ba25
@@ -1640,7 +1639,7 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
26ba25
 
26ba25
     ret = bdrv_get_info(bs, &bdi;;
26ba25
     if (ret) {
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     cvtstr(bdi.cluster_size, s1, sizeof(s1));
26ba25
@@ -1655,8 +1654,6 @@ static int info_f(BlockBackend *blk, int argc, char **argv)
26ba25
         bdrv_image_info_specific_dump(fprintf, stdout, spec_info);
26ba25
         qapi_free_ImageInfoSpecific(spec_info);
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 
26ba25
@@ -1683,7 +1680,7 @@ static void discard_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int discard_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void discard_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t discard_cmd = {
26ba25
     .name       = "discard",
26ba25
@@ -1697,7 +1694,7 @@ static const cmdinfo_t discard_cmd = {
26ba25
     .help       = discard_help,
26ba25
 };
26ba25
 
26ba25
-static int discard_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void discard_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     struct timeval t1, t2;
26ba25
     bool Cflag = false, qflag = false;
26ba25
@@ -1713,30 +1710,32 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
26ba25
             qflag = true;
26ba25
             break;
26ba25
         default:
26ba25
-            return qemuio_command_usage(&discard_cmd);
26ba25
+            qemuio_command_usage(&discard_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind != argc - 2) {
26ba25
-        return qemuio_command_usage(&discard_cmd);
26ba25
+        qemuio_command_usage(&discard_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     offset = cvtnum(argv[optind]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     optind++;
26ba25
     bytes = cvtnum(argv[optind]);
26ba25
     if (bytes < 0) {
26ba25
         print_cvtnum_err(bytes, argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     } else if (bytes >> BDRV_SECTOR_BITS > BDRV_REQUEST_MAX_SECTORS) {
26ba25
         printf("length cannot exceed %"PRIu64", given %s\n",
26ba25
                (uint64_t)BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS,
26ba25
                argv[optind]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     gettimeofday(&t1, NULL);
26ba25
@@ -1745,7 +1744,7 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
26ba25
 
26ba25
     if (ret < 0) {
26ba25
         printf("discard failed: %s\n", strerror(-ret));
26ba25
-        goto out;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     /* Finally, report back -- -C gives a parsable format */
26ba25
@@ -1753,12 +1752,9 @@ static int discard_f(BlockBackend *blk, int argc, char **argv)
26ba25
         t2 = tsub(t2, t1);
26ba25
         print_report("discard", &t2, offset, bytes, bytes, 1, Cflag);
26ba25
     }
26ba25
-
26ba25
-out:
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
-static int alloc_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void alloc_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     BlockDriverState *bs = blk_bs(blk);
26ba25
     int64_t offset, start, remaining, count;
26ba25
@@ -1769,14 +1765,14 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)
26ba25
     start = offset = cvtnum(argv[1]);
26ba25
     if (offset < 0) {
26ba25
         print_cvtnum_err(offset, argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (argc == 3) {
26ba25
         count = cvtnum(argv[2]);
26ba25
         if (count < 0) {
26ba25
             print_cvtnum_err(count, argv[2]);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
     } else {
26ba25
         count = BDRV_SECTOR_SIZE;
26ba25
@@ -1788,7 +1784,7 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)
26ba25
         ret = bdrv_is_allocated(bs, offset, remaining, &num);
26ba25
         if (ret < 0) {
26ba25
             printf("is_allocated failed: %s\n", strerror(-ret));
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
         offset += num;
26ba25
         remaining -= num;
26ba25
@@ -1805,7 +1801,6 @@ static int alloc_f(BlockBackend *blk, int argc, char **argv)
26ba25
 
26ba25
     printf("%"PRId64"/%"PRId64" bytes allocated at offset %s\n",
26ba25
            sum_alloc, count, s1);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t alloc_cmd = {
26ba25
@@ -1851,7 +1846,7 @@ static int map_is_allocated(BlockDriverState *bs, int64_t offset,
26ba25
     return firstret;
26ba25
 }
26ba25
 
26ba25
-static int map_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void map_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int64_t offset, bytes;
26ba25
     char s1[64], s2[64];
26ba25
@@ -1863,17 +1858,17 @@ static int map_f(BlockBackend *blk, int argc, char **argv)
26ba25
     bytes = blk_getlength(blk);
26ba25
     if (bytes < 0) {
26ba25
         error_report("Failed to query image length: %s", strerror(-bytes));
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     while (bytes) {
26ba25
         ret = map_is_allocated(blk_bs(blk), offset, bytes, &num);
26ba25
         if (ret < 0) {
26ba25
             error_report("Failed to get allocation status: %s", strerror(-ret));
26ba25
-            return 0;
26ba25
+            return;
26ba25
         } else if (!num) {
26ba25
             error_report("Unexpected end of image");
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
 
26ba25
         retstr = ret ? "    allocated" : "not allocated";
26ba25
@@ -1885,8 +1880,6 @@ static int map_f(BlockBackend *blk, int argc, char **argv)
26ba25
         offset += num;
26ba25
         bytes -= num;
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t map_cmd = {
26ba25
@@ -1914,7 +1907,7 @@ static void reopen_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int reopen_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void reopen_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static QemuOptsList reopen_opts = {
26ba25
     .name = "reopen",
26ba25
@@ -1936,7 +1929,7 @@ static const cmdinfo_t reopen_cmd = {
26ba25
        .help           = reopen_help,
26ba25
 };
26ba25
 
26ba25
-static int reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     BlockDriverState *bs = blk_bs(blk);
26ba25
     QemuOpts *qopts;
26ba25
@@ -1954,19 +1947,19 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
         case 'c':
26ba25
             if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
26ba25
                 error_report("Invalid cache option: %s", optarg);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'o':
26ba25
             if (!qemu_opts_parse_noisily(&reopen_opts, optarg, 0)) {
26ba25
                 qemu_opts_reset(&reopen_opts);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'r':
26ba25
             if (has_rw_option) {
26ba25
                 error_report("Only one -r/-w option may be given");
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             flags &= ~BDRV_O_RDWR;
26ba25
             has_rw_option = true;
26ba25
@@ -1974,20 +1967,22 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
         case 'w':
26ba25
             if (has_rw_option) {
26ba25
                 error_report("Only one -r/-w option may be given");
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             flags |= BDRV_O_RDWR;
26ba25
             has_rw_option = true;
26ba25
             break;
26ba25
         default:
26ba25
             qemu_opts_reset(&reopen_opts);
26ba25
-            return qemuio_command_usage(&reopen_cmd);
26ba25
+            qemuio_command_usage(&reopen_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
     if (optind != argc) {
26ba25
         qemu_opts_reset(&reopen_opts);
26ba25
-        return qemuio_command_usage(&reopen_cmd);
26ba25
+        qemuio_command_usage(&reopen_cmd);
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (writethrough != blk_enable_write_cache(blk) &&
26ba25
@@ -1995,7 +1990,7 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
     {
26ba25
         error_report("Cannot change cache.writeback: Device attached");
26ba25
         qemu_opts_reset(&reopen_opts);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     if (!(flags & BDRV_O_RDWR)) {
26ba25
@@ -2024,11 +2019,9 @@ static int reopen_f(BlockBackend *blk, int argc, char **argv)
26ba25
     } else {
26ba25
         blk_set_enable_write_cache(blk, !writethrough);
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
-static int break_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void break_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int ret;
26ba25
 
26ba25
@@ -2036,11 +2029,9 @@ static int break_f(BlockBackend *blk, int argc, char **argv)
26ba25
     if (ret < 0) {
26ba25
         printf("Could not set breakpoint: %s\n", strerror(-ret));
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
-static int remove_break_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void remove_break_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int ret;
26ba25
 
26ba25
@@ -2048,8 +2039,6 @@ static int remove_break_f(BlockBackend *blk, int argc, char **argv)
26ba25
     if (ret < 0) {
26ba25
         printf("Could not remove breakpoint %s: %s\n", argv[1], strerror(-ret));
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t break_cmd = {
26ba25
@@ -2071,7 +2060,7 @@ static const cmdinfo_t remove_break_cmd = {
26ba25
        .oneline        = "remove a breakpoint by tag",
26ba25
 };
26ba25
 
26ba25
-static int resume_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void resume_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int ret;
26ba25
 
26ba25
@@ -2079,8 +2068,6 @@ static int resume_f(BlockBackend *blk, int argc, char **argv)
26ba25
     if (ret < 0) {
26ba25
         printf("Could not resume request: %s\n", strerror(-ret));
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t resume_cmd = {
26ba25
@@ -2092,13 +2079,11 @@ static const cmdinfo_t resume_cmd = {
26ba25
        .oneline        = "resumes the request tagged as tag",
26ba25
 };
26ba25
 
26ba25
-static int wait_break_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void wait_break_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     while (!bdrv_debug_is_suspended(blk_bs(blk), argv[1])) {
26ba25
         aio_poll(blk_get_aio_context(blk), true);
26ba25
     }
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t wait_break_cmd = {
26ba25
@@ -2110,7 +2095,7 @@ static const cmdinfo_t wait_break_cmd = {
26ba25
        .oneline        = "waits for the suspension of a request",
26ba25
 };
26ba25
 
26ba25
-static int abort_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void abort_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     abort();
26ba25
 }
26ba25
@@ -2136,7 +2121,7 @@ static void sigraise_help(void)
26ba25
 "\n", SIGTERM);
26ba25
 }
26ba25
 
26ba25
-static int sigraise_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void sigraise_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t sigraise_cmd = {
26ba25
     .name       = "sigraise",
26ba25
@@ -2149,16 +2134,16 @@ static const cmdinfo_t sigraise_cmd = {
26ba25
     .help       = sigraise_help,
26ba25
 };
26ba25
 
26ba25
-static int sigraise_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void sigraise_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int64_t sig = cvtnum(argv[1]);
26ba25
     if (sig < 0) {
26ba25
         print_cvtnum_err(sig, argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     } else if (sig > NSIG) {
26ba25
         printf("signal argument '%s' is too large to be a valid signal\n",
26ba25
                argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     /* Using raise() to kill this process does not necessarily flush all open
26ba25
@@ -2168,7 +2153,6 @@ static int sigraise_f(BlockBackend *blk, int argc, char **argv)
26ba25
     fflush(stderr);
26ba25
 
26ba25
     raise(sig);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static void sleep_cb(void *opaque)
26ba25
@@ -2177,7 +2161,7 @@ static void sleep_cb(void *opaque)
26ba25
     *expired = true;
26ba25
 }
26ba25
 
26ba25
-static int sleep_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void sleep_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     char *endptr;
26ba25
     long ms;
26ba25
@@ -2187,7 +2171,7 @@ static int sleep_f(BlockBackend *blk, int argc, char **argv)
26ba25
     ms = strtol(argv[1], &endptr, 0);
26ba25
     if (ms < 0 || *endptr != '\0') {
26ba25
         printf("%s is not a valid number\n", argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     timer = timer_new_ns(QEMU_CLOCK_HOST, sleep_cb, &expired);
26ba25
@@ -2198,8 +2182,6 @@ static int sleep_f(BlockBackend *blk, int argc, char **argv)
26ba25
     }
26ba25
 
26ba25
     timer_free(timer);
26ba25
-
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t sleep_cmd = {
26ba25
@@ -2246,23 +2228,22 @@ static void help_all(void)
26ba25
     printf("\nUse 'help commandname' for extended help.\n");
26ba25
 }
26ba25
 
26ba25
-static int help_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void help_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     const cmdinfo_t *ct;
26ba25
 
26ba25
     if (argc == 1) {
26ba25
         help_all();
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     ct = find_command(argv[1]);
26ba25
     if (ct == NULL) {
26ba25
         printf("command %s not found\n", argv[1]);
26ba25
-        return 0;
26ba25
+        return;
26ba25
     }
26ba25
 
26ba25
     help_onecmd(argv[1], ct);
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t help_cmd = {
26ba25
@@ -2276,14 +2257,13 @@ static const cmdinfo_t help_cmd = {
26ba25
     .oneline    = "help for one or all commands",
26ba25
 };
26ba25
 
26ba25
-bool qemuio_command(BlockBackend *blk, const char *cmd)
26ba25
+void qemuio_command(BlockBackend *blk, const char *cmd)
26ba25
 {
26ba25
     AioContext *ctx;
26ba25
     char *input;
26ba25
     const cmdinfo_t *ct;
26ba25
     char **v;
26ba25
     int c;
26ba25
-    bool done = false;
26ba25
 
26ba25
     input = g_strdup(cmd);
26ba25
     v = breakline(input, &c);
26ba25
@@ -2292,7 +2272,7 @@ bool qemuio_command(BlockBackend *blk, const char *cmd)
26ba25
         if (ct) {
26ba25
             ctx = blk ? blk_get_aio_context(blk) : qemu_get_aio_context();
26ba25
             aio_context_acquire(ctx);
26ba25
-            done = command(blk, ct, c, v);
26ba25
+            command(blk, ct, c, v);
26ba25
             aio_context_release(ctx);
26ba25
         } else {
26ba25
             fprintf(stderr, "command \"%s\" not found\n", v[0]);
26ba25
@@ -2300,8 +2280,6 @@ bool qemuio_command(BlockBackend *blk, const char *cmd)
26ba25
     }
26ba25
     g_free(input);
26ba25
     g_free(v);
26ba25
-
26ba25
-    return done;
26ba25
 }
26ba25
 
26ba25
 static void __attribute((constructor)) init_qemuio_commands(void)
26ba25
diff --git a/qemu-io.c b/qemu-io.c
26ba25
index 73c638f..02a67c9 100644
26ba25
--- a/qemu-io.c
26ba25
+++ b/qemu-io.c
26ba25
@@ -37,6 +37,7 @@
26ba25
 static char *progname;
26ba25
 
26ba25
 static BlockBackend *qemuio_blk;
26ba25
+static bool quit_qemu_io;
26ba25
 
26ba25
 /* qemu-io commands passed using -c */
26ba25
 static int ncmdline;
26ba25
@@ -65,11 +66,10 @@ static int get_eof_char(void)
26ba25
 #endif
26ba25
 }
26ba25
 
26ba25
-static int close_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void close_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     blk_unref(qemuio_blk);
26ba25
     qemuio_blk = NULL;
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t close_cmd = {
26ba25
@@ -136,7 +136,7 @@ static void open_help(void)
26ba25
 "\n");
26ba25
 }
26ba25
 
26ba25
-static int open_f(BlockBackend *blk, int argc, char **argv);
26ba25
+static void open_f(BlockBackend *blk, int argc, char **argv);
26ba25
 
26ba25
 static const cmdinfo_t open_cmd = {
26ba25
     .name       = "open",
26ba25
@@ -160,7 +160,7 @@ static QemuOptsList empty_opts = {
26ba25
     },
26ba25
 };
26ba25
 
26ba25
-static int open_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void open_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
     int flags = BDRV_O_UNMAP;
26ba25
     int readonly = 0;
26ba25
@@ -192,25 +192,25 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
26ba25
             if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
26ba25
                 error_report("Invalid cache option: %s", optarg);
26ba25
                 qemu_opts_reset(&empty_opts);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'd':
26ba25
             if (bdrv_parse_discard_flags(optarg, &flags) < 0) {
26ba25
                 error_report("Invalid discard option: %s", optarg);
26ba25
                 qemu_opts_reset(&empty_opts);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'o':
26ba25
             if (imageOpts) {
26ba25
                 printf("--image-opts and 'open -o' are mutually exclusive\n");
26ba25
                 qemu_opts_reset(&empty_opts);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             if (!qemu_opts_parse_noisily(&empty_opts, optarg, false)) {
26ba25
                 qemu_opts_reset(&empty_opts);
26ba25
-                return 0;
26ba25
+                return;
26ba25
             }
26ba25
             break;
26ba25
         case 'U':
26ba25
@@ -218,7 +218,8 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
26ba25
             break;
26ba25
         default:
26ba25
             qemu_opts_reset(&empty_opts);
26ba25
-            return qemuio_command_usage(&open_cmd);
26ba25
+            qemuio_command_usage(&open_cmd);
26ba25
+            return;
26ba25
         }
26ba25
     }
26ba25
 
26ba25
@@ -229,7 +230,7 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
26ba25
     if (imageOpts && (optind == argc - 1)) {
26ba25
         if (!qemu_opts_parse_noisily(&empty_opts, argv[optind], false)) {
26ba25
             qemu_opts_reset(&empty_opts);
26ba25
-            return 0;
26ba25
+            return;
26ba25
         }
26ba25
         optind++;
26ba25
     }
26ba25
@@ -246,12 +247,11 @@ static int open_f(BlockBackend *blk, int argc, char **argv)
26ba25
         qobject_unref(opts);
26ba25
         qemuio_command_usage(&open_cmd);
26ba25
     }
26ba25
-    return 0;
26ba25
 }
26ba25
 
26ba25
-static int quit_f(BlockBackend *blk, int argc, char **argv)
26ba25
+static void quit_f(BlockBackend *blk, int argc, char **argv)
26ba25
 {
26ba25
-    return 1;
26ba25
+    quit_qemu_io = true;
26ba25
 }
26ba25
 
26ba25
 static const cmdinfo_t quit_cmd = {
26ba25
@@ -392,18 +392,18 @@ static void prep_fetchline(void *opaque)
26ba25
 
26ba25
 static void command_loop(void)
26ba25
 {
26ba25
-    int i, done = 0, fetchable = 0, prompted = 0;
26ba25
+    int i, fetchable = 0, prompted = 0;
26ba25
     char *input;
26ba25
 
26ba25
-    for (i = 0; !done && i < ncmdline; i++) {
26ba25
-        done = qemuio_command(qemuio_blk, cmdline[i]);
26ba25
+    for (i = 0; !quit_qemu_io && i < ncmdline; i++) {
26ba25
+        qemuio_command(qemuio_blk, cmdline[i]);
26ba25
     }
26ba25
     if (cmdline) {
26ba25
         g_free(cmdline);
26ba25
         return;
26ba25
     }
26ba25
 
26ba25
-    while (!done) {
26ba25
+    while (!quit_qemu_io) {
26ba25
         if (!prompted) {
26ba25
             printf("%s", get_prompt());
26ba25
             fflush(stdout);
26ba25
@@ -421,7 +421,7 @@ static void command_loop(void)
26ba25
         if (input == NULL) {
26ba25
             break;
26ba25
         }
26ba25
-        done = qemuio_command(qemuio_blk, input);
26ba25
+        qemuio_command(qemuio_blk, input);
26ba25
         g_free(input);
26ba25
 
26ba25
         prompted = 0;
26ba25
-- 
26ba25
1.8.3.1
26ba25