summaryrefslogtreecommitdiff
path: root/avr
diff options
context:
space:
mode:
Diffstat (limited to 'avr')
-rw-r--r--avr/cmd_attach.c3
-rw-r--r--avr/cmd_boot.c6
-rw-r--r--avr/cmd_cpu.c8
-rw-r--r--avr/cmd_gpio.c3
-rw-r--r--avr/cmd_mem.c4
-rw-r--r--avr/cmd_misc.c3
-rw-r--r--avr/command.c6
-rw-r--r--avr/env.c3
-rw-r--r--avr/getopt-min.c2
9 files changed, 3 insertions, 35 deletions
diff --git a/avr/cmd_attach.c b/avr/cmd_attach.c
index 0949687..651404f 100644
--- a/avr/cmd_attach.c
+++ b/avr/cmd_attach.c
@@ -49,9 +49,6 @@ command_ret_t do_attach(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
return CMD_RET_SUCCESS;
}
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("darwo:"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c
index e26a8b1..dcf834d 100644
--- a/avr/cmd_boot.c
+++ b/avr/cmd_boot.c
@@ -106,9 +106,6 @@ command_ret_t do_bootcf(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int a
memcpy_P(&boot_param, cfboot, sizeof boot_param);
default_stages = boot_param.stages;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("vna:s:c:t:i:"))) != -1) {
switch (opt) {
@@ -256,9 +253,6 @@ command_ret_t do_go(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int argc,
uint32_t addr;
bool hold = 0;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("h"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_cpu.c b/avr/cmd_cpu.c
index 6f50a2a..d692211 100644
--- a/avr/cmd_cpu.c
+++ b/avr/cmd_cpu.c
@@ -204,9 +204,6 @@ command_ret_t do_cpu_test(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
uint32_t pulsewidth = 10; /* ms */
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
@@ -237,8 +234,6 @@ command_ret_t do_bus_test(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
char ch;
#if 0
- /* reset getopt() */
- optind = 0;
int opt;
while ((opt = getopt(argc, argv, PSTR("t:"))) != -1) {
switch (opt) {
@@ -331,9 +326,6 @@ command_ret_t do_cpu_freq(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int
uint8_t eimsk_save;
uint8_t mem_save[cpuinfo_length];
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("swnuc:t:"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_gpio.c b/avr/cmd_gpio.c
index 65a71be..549654f 100644
--- a/avr/cmd_gpio.c
+++ b/avr/cmd_gpio.c
@@ -173,9 +173,6 @@ command_ret_t do_gpio(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED, int arg
uint_fast8_t pinarg[GPIO_MAX];
uint_fast8_t pinargc;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
switch (opt) {
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index d641410..3e18770 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -204,9 +204,6 @@ command_ret_t do_mem_mw(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * co
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1) {
switch (opt) {
@@ -261,7 +258,6 @@ command_ret_t do_mem_mdc ( cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char *
(void) cmdtp;
(void) flag;
- optind = 0;
if (argv[0][1] != 'd') {
int opt;
while ((opt = getopt(argc, argv, PSTR("bwl"))) != -1)
diff --git a/avr/cmd_misc.c b/avr/cmd_misc.c
index a88ba72..72102c6 100644
--- a/avr/cmd_misc.c
+++ b/avr/cmd_misc.c
@@ -22,9 +22,6 @@ command_ret_t do_echo(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * cons
(void) cmdtp; (void) flag;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("n"))) != -1) {
switch (opt) {
diff --git a/avr/command.c b/avr/command.c
index ff3a685..8eb5bb7 100644
--- a/avr/command.c
+++ b/avr/command.c
@@ -262,9 +262,6 @@ command_ret_t do_help(cmd_tbl_t *cmdtp, uint_fast8_t flag UNUSED, int argc, char
#define OPT_USAGE 0x08
#define OPT_LONG 0x10
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("afk"))) != -1) {
switch (opt) {
@@ -708,7 +705,7 @@ static cmd_tbl_t *cmd_invocation_ptr;
* @param argv Arguments
* @return 0 if command succeeded, else non-zero (CMD_RET_...)
*/
-command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
+static command_ret_t cmd_call(cmd_tbl_t *cmdtp, uint_fast8_t flag, int argc, char * const argv[])
{
command_ret_t result;
@@ -770,6 +767,7 @@ command_ret_t cmd_process(uint_fast8_t flag, int argc, char * const argv[],
/* If OK so far, then do the command */
if (!rc) {
+ optind = 0; /* reset getopt() */
cmd_invocation_ptr = cmdtp;
rc = cmd_call(cmdtp, flag, argc, argv);
*repeatable &= (cmdtp->flags & CTBL_RPT) != 0;
diff --git a/avr/env.c b/avr/env.c
index add281c..3bb04c2 100644
--- a/avr/env.c
+++ b/avr/env.c
@@ -693,9 +693,6 @@ command_ret_t do_env_print(cmd_tbl_t *cmdtp UNUSED, uint_fast8_t flag UNUSED,
bool mode = 0;
command_ret_t rc = CMD_RET_SUCCESS;
- /* reset getopt() */
- optind = 0;
-
int opt;
while ((opt = getopt(argc, argv, PSTR("s"))) != -1) {
switch (opt) {
diff --git a/avr/getopt-min.c b/avr/getopt-min.c
index 8508f40..401beed 100644
--- a/avr/getopt-min.c
+++ b/avr/getopt-min.c
@@ -13,7 +13,7 @@
#include "common.h" /* definition of FLASH */
#include <string.h>
-int optind = 0; /* next argv[] index */
+int optind; /* next argv[] index */
char *optarg; /* option parameter if any */