[Lguest] [PATCH 3/3] tools: lguest: options need not be global

Davidlohr Bueso dave at gnu.org
Tue Aug 14 03:48:47 EST 2012


From: Davidlohr Bueso <dave at gnu.org>

Since the structure is only called from main(), move it there.
Also use standard requirement constants instead of numeric values.

Signed-off-by: Davidlohr Bueso <dave at gnu.org>
---
 tools/lguest/lguest.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tools/lguest/lguest.c b/tools/lguest/lguest.c
index ea8cccd..3c70454 100644
--- a/tools/lguest/lguest.c
+++ b/tools/lguest/lguest.c
@@ -1846,17 +1846,6 @@ static void __attribute__((noreturn)) run_guest(void)
  * "make Host".
 :*/
 
-static struct option opts[] = {
-	{ "verbose", 0, NULL, 'v' },
-	{ "tunnet", 1, NULL, 't' },
-	{ "block", 1, NULL, 'b' },
-	{ "rng", 0, NULL, 'r' },
-	{ "initrd", 1, NULL, 'i' },
-	{ "username", 1, NULL, 'u' },
-	{ "chroot", 1, NULL, 'c' },
-	{ NULL },
-};
-
 static void  __attribute__ ((__noreturn__)) usage(FILE *out)
 {
 	fprintf(out, "Usage: lguest [--verbose] "
@@ -1882,6 +1871,17 @@ int main(int argc, char *argv[])
 	/* Password structure for initgroups/setres[gu]id */
 	struct passwd *user_details = NULL;
 
+	static struct option opts[] = {
+		{ "verbose",  no_argument,       NULL, 'v' },
+		{ "tunnet",   required_argument, NULL, 't' },
+		{ "block",    required_argument, NULL, 'b' },
+		{ "rng",      no_argument,       NULL, 'r' },
+		{ "initrd",   required_argument, NULL, 'i' },
+		{ "username", required_argument, NULL, 'u' },
+		{ "chroot",   required_argument, NULL, 'c' },
+		{ NULL, 0, NULL, 0 },
+	};
+
 	/* Directory to chroot to */
 	char *chroot_path = NULL;
 
-- 
1.7.4.1






More information about the Lguest mailing list