Message ID | 1436205821-20320-2-git-send-email-meadori@codesourcery.com |
---|---|
State | New |
Headers | show |
Global comment: you should use EXIT_SUCCESS and EXIT_FAILURE from stdlib.h Le 06/07/2015 20:03, meadori@codesourcery.com a écrit : > From: Meador Inge <meadori@codesourcery.com> > > Signed-off-by: Meador Inge <meadori@codesourcery.com> > --- > linux-user/main.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/linux-user/main.c b/linux-user/main.c > index c855bcc..c6ab557 100644 > --- a/linux-user/main.c > +++ b/linux-user/main.c > @@ -65,7 +65,7 @@ unsigned long reserved_va; > #endif > #endif > > -static void usage(void); > +static void usage(int exitcode); > > static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; > const char *qemu_uname_release; > @@ -3473,7 +3473,7 @@ CPUArchState *cpu_copy(CPUArchState *env) > > static void handle_arg_help(const char *arg) > { > - usage(); > + usage(0); > } > > static void handle_arg_log(const char *arg) > @@ -3499,7 +3499,7 @@ static void handle_arg_set_env(const char *arg) > r = p = strdup(arg); > while ((token = strsep(&p, ",")) != NULL) { > if (envlist_setenv(envlist, token) != 0) { > - usage(); > + usage(1); > } > } > free(r); > @@ -3511,7 +3511,7 @@ static void handle_arg_unset_env(const char *arg) > r = p = strdup(arg); > while ((token = strsep(&p, ",")) != NULL) { > if (envlist_unsetenv(envlist, token) != 0) { > - usage(); > + usage(1); > } > } > free(r); > @@ -3527,7 +3527,7 @@ static void handle_arg_stack_size(const char *arg) > char *p; > guest_stack_size = strtoul(arg, &p, 0); > if (guest_stack_size == 0) { > - usage(); > + usage(1); > } > > if (*p == 'M') { > @@ -3698,7 +3698,7 @@ static const struct qemu_argument arg_table[] = { > {NULL, NULL, false, NULL, NULL, NULL} > }; > > -static void usage(void) > +static void usage(int exitcode) > { > const struct qemu_argument *arginfo; > int maxarglen; > @@ -3765,7 +3765,7 @@ static void usage(void) > "Note that if you provide several changes to a single variable\n" > "the last change will stay in effect.\n"); > > - exit(1); > + exit(exitcode); > } > > static int parse_args(int argc, char **argv) > @@ -3804,7 +3804,7 @@ static int parse_args(int argc, char **argv) > if (!strcmp(r, arginfo->argv)) { > if (arginfo->has_arg) { > if (optind >= argc) { > - usage(); > + usage(1); > } > arginfo->handle_opt(argv[optind]); > optind++; > @@ -3817,12 +3817,12 @@ static int parse_args(int argc, char **argv) > > /* no option matched the current argv */ > if (arginfo->handle_opt == NULL) { > - usage(); > + usage(1); > } > } > > if (optind >= argc) { > - usage(); > + usage(1); > } > > filename = argv[optind]; >
On Mon, Jul 06, 2015 at 09:43:20PM +0200, Laurent Vivier wrote:
> Global comment: you should use EXIT_SUCCESS and EXIT_FAILURE from stdlib.h
Will fix. Thanks.
-- Meador
On Mon, Jul 06, 2015 at 09:43:20PM +0200, Laurent Vivier wrote:
> Global comment: you should use EXIT_SUCCESS and EXIT_FAILURE from stdlib.h
On second thought, I was following an existing pattern in 'main.c'. Really
fixing this would require changing around 30 other locations too. I think
if we are going to switch to the EXIT_* macros, then the whole file should
be changed in one patch and making that fix shouldn't hold this patch up.
-- Meador
On Mon, Jul 13, 2015 at 01:08:02PM -0700, Meador Inge wrote: > On Mon, Jul 06, 2015 at 09:43:20PM +0200, Laurent Vivier wrote: > > > Global comment: you should use EXIT_SUCCESS and EXIT_FAILURE from stdlib.h > On second thought, I was following an existing pattern in 'main.c'. Really > fixing this would require changing around 30 other locations too. I think > if we are going to switch to the EXIT_* macros, then the whole file should > be changed in one patch and making that fix shouldn't hold this patch up. I've just done a commit to for wholesale transition. This code is only ever compiled for Linux, so portability doesn't matter. I think it makes the code a bit more self-documenting. Riku
diff --git a/linux-user/main.c b/linux-user/main.c index c855bcc..c6ab557 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -65,7 +65,7 @@ unsigned long reserved_va; #endif #endif -static void usage(void); +static void usage(int exitcode); static const char *interp_prefix = CONFIG_QEMU_INTERP_PREFIX; const char *qemu_uname_release; @@ -3473,7 +3473,7 @@ CPUArchState *cpu_copy(CPUArchState *env) static void handle_arg_help(const char *arg) { - usage(); + usage(0); } static void handle_arg_log(const char *arg) @@ -3499,7 +3499,7 @@ static void handle_arg_set_env(const char *arg) r = p = strdup(arg); while ((token = strsep(&p, ",")) != NULL) { if (envlist_setenv(envlist, token) != 0) { - usage(); + usage(1); } } free(r); @@ -3511,7 +3511,7 @@ static void handle_arg_unset_env(const char *arg) r = p = strdup(arg); while ((token = strsep(&p, ",")) != NULL) { if (envlist_unsetenv(envlist, token) != 0) { - usage(); + usage(1); } } free(r); @@ -3527,7 +3527,7 @@ static void handle_arg_stack_size(const char *arg) char *p; guest_stack_size = strtoul(arg, &p, 0); if (guest_stack_size == 0) { - usage(); + usage(1); } if (*p == 'M') { @@ -3698,7 +3698,7 @@ static const struct qemu_argument arg_table[] = { {NULL, NULL, false, NULL, NULL, NULL} }; -static void usage(void) +static void usage(int exitcode) { const struct qemu_argument *arginfo; int maxarglen; @@ -3765,7 +3765,7 @@ static void usage(void) "Note that if you provide several changes to a single variable\n" "the last change will stay in effect.\n"); - exit(1); + exit(exitcode); } static int parse_args(int argc, char **argv) @@ -3804,7 +3804,7 @@ static int parse_args(int argc, char **argv) if (!strcmp(r, arginfo->argv)) { if (arginfo->has_arg) { if (optind >= argc) { - usage(); + usage(1); } arginfo->handle_opt(argv[optind]); optind++; @@ -3817,12 +3817,12 @@ static int parse_args(int argc, char **argv) /* no option matched the current argv */ if (arginfo->handle_opt == NULL) { - usage(); + usage(1); } } if (optind >= argc) { - usage(); + usage(1); } filename = argv[optind];