[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] qemu-img: Exit with code 0 if there is no error
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH] qemu-img: Exit with code 0 if there is no error |
Date: |
Fri, 18 Apr 2014 14:23:24 +0800 |
Signed-off-by: Fam Zheng <address@hidden>
---
qemu-img.c | 68 +++++++++++++++++++++++++++++++-------------------------------
1 file changed, 34 insertions(+), 34 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 8455994..756ccb1 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -58,7 +58,7 @@ static void format_print(void *opaque, const char *name)
}
/* Please keep in synch with qemu-img.texi */
-static void help(void)
+static void help(bool error)
{
const char *help_msg =
"qemu-img version " QEMU_VERSION ", Copyright (c) 2004-2008 Fabrice
Bellard\n"
@@ -129,7 +129,7 @@ static void help(void)
printf("%s\nSupported formats:", help_msg);
bdrv_iterate_format(format_print, NULL);
printf("\n");
- exit(1);
+ exit(error ? 1 : 0);
}
static int GCC_FMT_ATTR(2, 3) qprintf(bool quiet, const char *fmt, ...)
@@ -352,7 +352,7 @@ static int img_create(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'F':
base_fmt = optarg;
@@ -398,7 +398,7 @@ static int img_create(int argc, char **argv)
}
if (optind >= argc) {
- help();
+ help(true);
}
optind++;
@@ -421,7 +421,7 @@ static int img_create(int argc, char **argv)
img_size = (uint64_t)sval;
}
if (optind != argc) {
- help();
+ help(true);
}
bdrv_img_create(filename, fmt, base_filename, base_fmt,
@@ -577,7 +577,7 @@ static int img_check(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -590,7 +590,7 @@ static int img_check(int argc, char **argv)
} else if (!strcmp(optarg, "all")) {
fix = BDRV_FIX_LEAKS | BDRV_FIX_ERRORS;
} else {
- help();
+ help(true);
}
break;
case OPTION_OUTPUT:
@@ -602,7 +602,7 @@ static int img_check(int argc, char **argv)
}
}
if (optind != argc - 1) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -699,7 +699,7 @@ static int img_commit(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -713,7 +713,7 @@ static int img_commit(int argc, char **argv)
}
}
if (optind != argc - 1) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -932,7 +932,7 @@ static int img_compare(int argc, char **argv)
switch (c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt1 = optarg;
@@ -959,7 +959,7 @@ static int img_compare(int argc, char **argv)
if (optind != argc - 2) {
- help();
+ help(true);
}
filename1 = argv[optind++];
filename2 = argv[optind++];
@@ -1176,7 +1176,7 @@ static int img_convert(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -1275,7 +1275,7 @@ static int img_convert(int argc, char **argv)
}
if (bs_n < 1) {
- help();
+ help(true);
}
@@ -1868,7 +1868,7 @@ static int img_info(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -1882,7 +1882,7 @@ static int img_info(int argc, char **argv)
}
}
if (optind != argc - 1) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -2036,7 +2036,7 @@ static int img_map(int argc, char **argv)
switch (c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -2047,7 +2047,7 @@ static int img_map(int argc, char **argv)
}
}
if (optind >= argc) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -2134,11 +2134,11 @@ static int img_snapshot(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
return 0;
case 'l':
if (action) {
- help();
+ help(true);
return 0;
}
action = SNAPSHOT_LIST;
@@ -2146,7 +2146,7 @@ static int img_snapshot(int argc, char **argv)
break;
case 'a':
if (action) {
- help();
+ help(true);
return 0;
}
action = SNAPSHOT_APPLY;
@@ -2154,7 +2154,7 @@ static int img_snapshot(int argc, char **argv)
break;
case 'c':
if (action) {
- help();
+ help(true);
return 0;
}
action = SNAPSHOT_CREATE;
@@ -2162,7 +2162,7 @@ static int img_snapshot(int argc, char **argv)
break;
case 'd':
if (action) {
- help();
+ help(true);
return 0;
}
action = SNAPSHOT_DELETE;
@@ -2175,7 +2175,7 @@ static int img_snapshot(int argc, char **argv)
}
if (optind != argc - 1) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -2258,7 +2258,7 @@ static int img_rebase(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
return 0;
case 'f':
fmt = optarg;
@@ -2289,7 +2289,7 @@ static int img_rebase(int argc, char **argv)
}
if ((optind != argc - 1) || (!unsafe && !out_baseimg)) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -2549,7 +2549,7 @@ static int img_resize(int argc, char **argv)
/* Remove size from argv manually so that negative numbers are not treated
* as options by getopt. */
if (argc < 3) {
- help();
+ help(true);
return 1;
}
@@ -2565,7 +2565,7 @@ static int img_resize(int argc, char **argv)
switch(c) {
case '?':
case 'h':
- help();
+ help(false);
break;
case 'f':
fmt = optarg;
@@ -2576,7 +2576,7 @@ static int img_resize(int argc, char **argv)
}
}
if (optind != argc - 1) {
- help();
+ help(true);
}
filename = argv[optind++];
@@ -2666,7 +2666,7 @@ static int img_amend(int argc, char **argv)
switch (c) {
case 'h':
case '?':
- help();
+ help(false);
break;
case 'o':
if (!is_valid_option_list(optarg)) {
@@ -2692,7 +2692,7 @@ static int img_amend(int argc, char **argv)
}
if (!options) {
- help();
+ help(true);
}
filename = (optind == argc - 1) ? argv[argc - 1] : NULL;
@@ -2704,7 +2704,7 @@ static int img_amend(int argc, char **argv)
}
if (optind != argc - 1) {
- help();
+ help(true);
}
bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR, true, quiet);
@@ -2776,7 +2776,7 @@ int main(int argc, char **argv)
qemu_init_main_loop();
bdrv_init();
if (argc < 2)
- help();
+ help(true);
cmdname = argv[1];
argc--; argv++;
@@ -2788,6 +2788,6 @@ int main(int argc, char **argv)
}
/* not found */
- help();
+ help(true);
return 0;
}
--
1.9.2
- [Qemu-devel] [PATCH] qemu-img: Exit with code 0 if there is no error,
Fam Zheng <=