Blame SOURCES/kvm-qemu-io-Drop-command-functions-return-values.patch

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