summaryrefslogtreecommitdiff
path: root/avr
diff options
context:
space:
mode:
authorLeo C2015-10-23 15:14:56 +0200
committerLeo C2015-10-23 15:14:56 +0200
commitaca998c354db4006fd821a47b09e55775c61371d (patch)
tree8b615a211d8dbebee88605a81ebc7c580281221f /avr
parented7d7fd35e5cf408fd9cf7e900308b4ce318be7c (diff)
downloadz180-stamp-aca998c354db4006fd821a47b09e55775c61371d.zip
cli.c: bugfix in cli_parse_line(): correct nargs
Diffstat (limited to 'avr')
-rw-r--r--avr/cli.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/avr/cli.c b/avr/cli.c
index 43b5be0..e66554a 100644
--- a/avr/cli.c
+++ b/avr/cli.c
@@ -44,9 +44,7 @@ static int cli_parse_line(char *line, char *argv[])
debug_parser("%s: \"%s\"\n", __func__, line);
- for (outp = inp = line, quote = '\0' ;
- nargs < CONFIG_SYS_MAXARGS && (c = *inp) != '\0';
- inp++) {
+ for (outp = inp = line, quote = '\0'; (c = *inp) != '\0'; inp++) {
switch (state) {
case 0: /* before arg string, waiting for arg start */
@@ -91,6 +89,11 @@ static int cli_parse_line(char *line, char *argv[])
break;
}
+
+ if (nargs > CONFIG_SYS_MAXARGS) {
+ --nargs;
+ break;
+ }
*outp++ = c;
}
@@ -397,7 +400,7 @@ command_ret_t do_run(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
arg = getenv(argv[i]);
if (arg == NULL) {
- printf_P(PSTR("## Error: \"%s\" not defined\n"), argv[i]);
+ printf_P(PSTR("## Error: \"%s\" is not set\n"), argv[i]);
return CMD_RET_FAILURE;
}