提交 15f82208 编写于 作者: T ths

Sanitize exit codes of help queries, this time for real.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3034 c046a42c-6fe2-441c-8c8c-71466251a162
上级 5a84a5dd
...@@ -6570,7 +6570,7 @@ int main_loop(void) ...@@ -6570,7 +6570,7 @@ int main_loop(void)
return ret; return ret;
} }
static void help(const char *optarg) static void help(int exitcode)
{ {
printf("QEMU PC emulator version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n" printf("QEMU PC emulator version " QEMU_VERSION ", Copyright (c) 2003-2007 Fabrice Bellard\n"
"usage: %s [options] [disk_image]\n" "usage: %s [options] [disk_image]\n"
...@@ -6712,7 +6712,7 @@ static void help(const char *optarg) ...@@ -6712,7 +6712,7 @@ static void help(const char *optarg)
#endif #endif
DEFAULT_GDBSTUB_PORT, DEFAULT_GDBSTUB_PORT,
"/tmp/qemu.log"); "/tmp/qemu.log");
exit(strcmp(optarg, "?")); exit(exitcode);
} }
#define HAS_ARG 0x0001 #define HAS_ARG 0x0001
...@@ -7283,12 +7283,12 @@ int main(int argc, char **argv) ...@@ -7283,12 +7283,12 @@ int main(int argc, char **argv)
m->name, m->desc, m->name, m->desc,
m == first_machine ? " (default)" : ""); m == first_machine ? " (default)" : "");
} }
exit(1); exit(*optarg != '?');
} }
break; break;
case QEMU_OPTION_cpu: case QEMU_OPTION_cpu:
/* hw initialization will check this */ /* hw initialization will check this */
if (optarg[0] == '?') { if (*optarg == '?') {
#if defined(TARGET_PPC) #if defined(TARGET_PPC)
ppc_cpu_list(stdout, &fprintf); ppc_cpu_list(stdout, &fprintf);
#elif defined(TARGET_ARM) #elif defined(TARGET_ARM)
...@@ -7298,7 +7298,7 @@ int main(int argc, char **argv) ...@@ -7298,7 +7298,7 @@ int main(int argc, char **argv)
#elif defined(TARGET_SPARC) #elif defined(TARGET_SPARC)
sparc_cpu_list(stdout, &fprintf); sparc_cpu_list(stdout, &fprintf);
#endif #endif
exit(1); exit(0);
} else { } else {
cpu_model = optarg; cpu_model = optarg;
} }
...@@ -7452,12 +7452,12 @@ int main(int argc, char **argv) ...@@ -7452,12 +7452,12 @@ int main(int argc, char **argv)
break; break;
#endif #endif
case QEMU_OPTION_h: case QEMU_OPTION_h:
help(optarg); help(0);
break; break;
case QEMU_OPTION_m: case QEMU_OPTION_m:
ram_size = atoi(optarg) * 1024 * 1024; ram_size = atoi(optarg) * 1024 * 1024;
if (ram_size <= 0) if (ram_size <= 0)
help(optarg); help(1);
if (ram_size > PHYS_RAM_MAX_SIZE) { if (ram_size > PHYS_RAM_MAX_SIZE) {
fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n", fprintf(stderr, "qemu: at most %d MB RAM can be simulated\n",
PHYS_RAM_MAX_SIZE / (1024 * 1024)); PHYS_RAM_MAX_SIZE / (1024 * 1024));
...@@ -7743,7 +7743,7 @@ int main(int argc, char **argv) ...@@ -7743,7 +7743,7 @@ int main(int argc, char **argv)
hd_filename[0] == '\0' && hd_filename[0] == '\0' &&
(cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') && (cdrom_index >= 0 && hd_filename[cdrom_index] == '\0') &&
fd_filename[0] == '\0') fd_filename[0] == '\0')
help(""); help(1);
/* boot to floppy or the default cd if no hard disk defined yet */ /* boot to floppy or the default cd if no hard disk defined yet */
if (hd_filename[0] == '\0' && boot_device == 'c') { if (hd_filename[0] == '\0' && boot_device == 'c') {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册