[Lguest] [PATCH 1/3] tools: lguest: redo usage
Rusty Russell
rusty at rustcorp.com.au
Tue Aug 14 10:18:56 EST 2012
On Mon, 13 Aug 2012 19:48:21 +0200, Davidlohr Bueso <dave at gnu.org> wrote:
> From: Davidlohr Bueso <dave at gnu.org>
>
> Add noreturn attribute and allow passing the output file in case of calling
> upon error or expected behavior.
>
> Signed-off-by: Davidlohr Bueso <dave at gnu.org>
Except this is unused...
Your patches are all so minor that they're almost a noop. I'll apply
them, but only once you send me an actual enhancement or bugfix :)
Cheers,
Rusty.
> ---
> tools/lguest/lguest.c | 17 ++++++++++-------
> 1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c
> index f759f4f..931b6ff 100644
> --- a/tools/lguest/lguest.c
> +++ b/tools/lguest/lguest.c
> @@ -1856,12 +1856,15 @@ static struct option opts[] = {
> { "chroot", 1, NULL, 'c' },
> { NULL },
> };
> -static void usage(void)
> +
> +static void __attribute__ ((__noreturn__)) usage(FILE *out)
> {
> - errx(1, "Usage: lguest [--verbose] "
> - "[--tunnet=(<ipaddr>:<macaddr>|bridge:<bridgename>:<macaddr>)\n"
> - "|--block=<filename>|--initrd=<filename>]...\n"
> - "<mem-in-mb> vmlinux [args...]");
> + fprintf(out, "Usage: lguest [--verbose] "
> + "[--tunnet=(<ipaddr>:<macaddr>|bridge:<bridgename>:<macaddr>)\n"
> + "|--block=<filename>|--initrd=<filename>]...\n"
> + "<mem-in-mb> vmlinux [args...]\n");
> +
> + exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
> }
>
> /*L:105 The main routine is where the real work begins: */
> @@ -1948,7 +1951,7 @@ int main(int argc, char *argv[])
> break;
> default:
> warnx("Unknown argument %s", argv[optind]);
> - usage();
> + usage(stderr);
> }
> }
> /*
> @@ -1956,7 +1959,7 @@ int main(int argc, char *argv[])
> * followed by command line arguments for the kernel.
> */
> if (optind + 2 > argc)
> - usage();
> + usage(stderr);
>
> verbose("Guest base is at %p\n", guest_base);
>
> --
> 1.7.4.1
>
>
>
>
More information about the Lguest
mailing list