On Mon, Sep 12, 2016 at 4:59 AM, Emil Velikov <emil.l.veli...@gmail.com> wrote: > From: Emil Velikov <emil.veli...@collabora.com> > > Derive file locally and exit() accordingly based on the bool. > Allows us to save a couple lines of code. >
If we're nit-picking, I'd rather just pass the exit code than a bool parameter. Kristian > Signed-off-by: Emil Velikov <emil.veli...@collabora.com> > --- > s/print_help/print_help_and_exit/ and/or too bike sheddy ? > --- > src/intel/tools/aubinator.c | 22 ++++++++++------------ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c > index 9d29b68..e48ab3e 100644 > --- a/src/intel/tools/aubinator.c > +++ b/src/intel/tools/aubinator.c > @@ -1011,8 +1011,10 @@ setup_pager(void) > } > > static void > -print_help(const char *progname, FILE *file) > +print_help(const char *progname, bool critical) > { > + FILE *file = critical ? stderr : stdout; > + > fprintf(file, > "Usage: %s [OPTION]... FILE\n" > "Decode aub file contents.\n\n" > @@ -1025,6 +1027,7 @@ print_help(const char *progname, FILE *file) > " --no-pager don't launch pager\n" > " --no-offsets don't print instruction offsets\n", > progname); > + exit(critical ? EXIT_FAILURE : EXIT_SUCCESS); > } > > static bool > @@ -1054,10 +1057,8 @@ int main(int argc, char *argv[]) > const char *value; > char gen_file[256], gen_val[24]; > > - if (argc == 1) { > - print_help(argv[0], stderr); > - exit(EXIT_FAILURE); > - } > + if (argc == 1) > + print_help(argv[0], true); > > for (i = 1; i < argc; ++i) { > if (strcmp(argv[i], "--no-pager") == 0) { > @@ -1087,8 +1088,7 @@ int main(int argc, char *argv[]) > exit(EXIT_FAILURE); > } > } else if (strcmp(argv[i], "--help") == 0) { > - print_help(argv[0], stdout); > - exit(EXIT_SUCCESS); > + print_help(argv[0], false); > } else { > if (argv[i][0] == '-') { > fprintf(stderr, "unknown option %s\n", argv[i]); > @@ -1166,12 +1166,10 @@ int main(int argc, char *argv[]) > spec = gen_spec_load(gen_file); > disasm = gen_disasm_create(pci_id); > > - if (argv[i] == NULL) { > - print_help(argv[0], stderr); > - exit(EXIT_FAILURE); > - } else { > + if (argv[i] == NULL) > + print_help(argv[0], true); > + else > file = aub_file_open(argv[i]); > - } > > while (aub_file_more_stuff(file)) > aub_file_decode_batch(file, spec); > -- > 2.9.3 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev