[PATCH 2/4] automount: fix argument parsing

Sascha Hauer s.hauer at pengutronix.de
Sun Apr 15 10:51:55 EDT 2012


With getopt we have to use argv[optind] instead of hardcoded argv[0]

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/automount.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/commands/automount.c b/commands/automount.c
index 5fc68f3..8c0e4de 100644
--- a/commands/automount.c
+++ b/commands/automount.c
@@ -40,10 +40,10 @@ static int do_automount(int argc, char *argv[])
 		}
 	}
 
-	if (argc != 3)
+	if (optind + 2 != argc)
 		return COMMAND_ERROR_USAGE;
 
-	ret = automount_add(argv[1], argv[2]);
+	ret = automount_add(argv[optind], argv[optind + 1]);
 	if (ret)
 		printf("adding automountpoint failed: %s\n",
 				strerror(-ret));
-- 
1.7.10




More information about the barebox mailing list