From 63e01b4969c9eef70b45df279f43a786b0cb2c09 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sat, 17 Oct 2009 12:49:47 +0200 Subject: call getopt_reset only once instead of calling getopt_reset in each command, call it only once before calling the command. Signed-off-by: Sascha Hauer --- arch/arm/mach-imx/clko.c | 2 -- commands/bmp.c | 2 -- commands/bootm.c | 2 -- commands/crc.c | 2 -- commands/dfu.c | 1 - commands/loadb.c | 2 -- commands/ls.c | 2 -- commands/mem.c | 2 -- commands/mkdir.c | 2 -- commands/nand.c | 2 -- commands/timeout.c | 2 -- common/command.c | 3 +++ 12 files changed, 3 insertions(+), 21 deletions(-) diff --git a/arch/arm/mach-imx/clko.c b/arch/arm/mach-imx/clko.c index 9ef5ac8e1f..bdedd66b7d 100644 --- a/arch/arm/mach-imx/clko.c +++ b/arch/arm/mach-imx/clko.c @@ -8,8 +8,6 @@ static int do_clko (cmd_tbl_t *cmdtp, int argc, char *argv[]) { int opt, div = 0, src = -2, ret; - getopt_reset(); - while((opt = getopt(argc, argv, "d:s:")) > 0) { switch(opt) { case 'd': diff --git a/commands/bmp.c b/commands/bmp.c index b7b7c9f5fa..22d7275d8f 100644 --- a/commands/bmp.c +++ b/commands/bmp.c @@ -45,8 +45,6 @@ static int do_bmp(cmd_tbl_t *cmdtp, int argc, char *argv[]) int offscreen = 0; void *adr, *buf; - getopt_reset(); - while((opt = getopt(argc, argv, "f:x:y:o")) > 0) { switch(opt) { case 'f': diff --git a/commands/bootm.c b/commands/bootm.c index b9c58b1414..9e16e06815 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -377,8 +377,6 @@ static int do_bootm (cmd_tbl_t *cmdtp, int argc, char *argv[]) memset(&data, 0, sizeof(struct image_data)); data.verify = 1; - getopt_reset(); - /* Collect options from registered handlers */ strcpy(options, "nh"); list_for_each_entry(handler, &handler_list, list) { diff --git a/commands/crc.c b/commands/crc.c index 7ac69c60f9..d828bc987c 100644 --- a/commands/crc.c +++ b/commands/crc.c @@ -38,8 +38,6 @@ static int do_crc (cmd_tbl_t *cmdtp, int argc, char *argv[]) char *buf; int fd, opt, err = 0, filegiven = 0, verify = 0, now; - getopt_reset(); - while((opt = getopt(argc, argv, "f:v:")) > 0) { switch(opt) { case 'f': diff --git a/commands/dfu.c b/commands/dfu.c index d35b129651..fae77021c0 100644 --- a/commands/dfu.c +++ b/commands/dfu.c @@ -105,7 +105,6 @@ static int do_dfu(cmd_tbl_t *cmdtp, int argc, char *argv[]) char *productname = CONFIG_BOARDINFO; u16 idVendor = 0, idProduct = 0; - getopt_reset(); while((opt = getopt(argc, argv, "m:p:V:P:")) > 0) { switch(opt) { diff --git a/commands/loadb.c b/commands/loadb.c index 890e977b2f..1fdf94487b 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -699,8 +699,6 @@ static int do_load_serial_bin(cmd_tbl_t *cmdtp, int argc, char *argv[]) char *output_file = NULL; struct console_device *cdev = NULL; - getopt_reset(); - while ((opt = getopt(argc, argv, "f:b:o:c")) > 0) { switch (opt) { case 'f': diff --git a/commands/ls.c b/commands/ls.c index 85fe8b53f4..2522546472 100644 --- a/commands/ls.c +++ b/commands/ls.c @@ -118,8 +118,6 @@ static int do_ls (cmd_tbl_t *cmdtp, int argc, char *argv[]) ulong flags = LS_COLUMN; struct string_list sl; - getopt_reset(); - while((opt = getopt(argc, argv, "RCl")) > 0) { switch(opt) { case 'R': diff --git a/commands/mem.c b/commands/mem.c index b31a8f47d1..dd6c497c51 100644 --- a/commands/mem.c +++ b/commands/mem.c @@ -138,8 +138,6 @@ static int mem_parse_options(int argc, char *argv[], char *optstr, int *mode, { int opt; - getopt_reset(); - while((opt = getopt(argc, argv, optstr)) > 0) { switch(opt) { case 'b': diff --git a/commands/mkdir.c b/commands/mkdir.c index 4d9bcb602b..a9c0b45356 100644 --- a/commands/mkdir.c +++ b/commands/mkdir.c @@ -30,8 +30,6 @@ static int do_mkdir (cmd_tbl_t *cmdtp, int argc, char *argv[]) { int opt, parent = 0, ret; - getopt_reset(); - while((opt = getopt(argc, argv, "p")) > 0) { switch(opt) { case 'p': diff --git a/commands/nand.c b/commands/nand.c index acec327dcd..b690966f65 100644 --- a/commands/nand.c +++ b/commands/nand.c @@ -271,8 +271,6 @@ static int do_nand(cmd_tbl_t *cmdtp, int argc, char *argv[]) struct nand_bb *bb; int command = 0, badblock = 0; - getopt_reset(); - while((opt = getopt(argc, argv, "adb:")) > 0) { if (command) { printf("only one command may be given\n"); diff --git a/commands/timeout.c b/commands/timeout.c index dbf17a7906..8093959216 100644 --- a/commands/timeout.c +++ b/commands/timeout.c @@ -37,8 +37,6 @@ static int do_timeout(cmd_tbl_t *cmdtp, int argc, char *argv[]) int flags = 0, opt, countdown; uint64_t start, second; - getopt_reset(); - while((opt = getopt(argc, argv, "t:crsa")) > 0) { switch(opt) { case 'r': diff --git a/common/command.c b/common/command.c index 52b9ee14ef..e6b4aff8b8 100644 --- a/common/command.c +++ b/common/command.c @@ -34,6 +34,7 @@ #include #include #include +#include const char version_string[] = "U-Boot " UTS_RELEASE " (" __DATE__ " - " __TIME__ ")"; @@ -96,6 +97,8 @@ int execute_command(int argc, char **argv) cmd_tbl_t *cmdtp; int ret; + getopt_reset(); + /* Look up command in command table */ if ((cmdtp = find_cmd(argv[0]))) { /* found - check max args */ -- cgit v1.2.3