[Lguest] [PATCH 1/3] tools: lguest: redo usage
Davidlohr Bueso
dave at gnu.org
Tue Aug 14 03:48:21 EST 2012
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>
---
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