diff options
author | Tom Rini <trini@konsulko.com> | 2020-12-07 17:16:23 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-12-07 17:16:23 -0500 |
commit | cd833de0593fa2346dddab21eff6ccf2411380d3 (patch) | |
tree | f87835b392c62414199e5fb926d0f4f63d92ec9e /common/cli_simple.c | |
parent | 5157ea526142ace7b0b19939b0d31ace4276cda7 (diff) | |
parent | 51bb33846ad2b045799d2c43ca773fafa36e6ec8 (diff) |
Merge branch '2020-12-07-bootm-and-spl-atf-improvements' into next
- Series to improve "bootm" by allowing variable evaluation within the
cmdline we would be passing. This will help with Chrome OS but can be
useful elsewhere.
- Improve ATF (TF-A) support within SPL.
Diffstat (limited to 'common/cli_simple.c')
-rw-r--r-- | common/cli_simple.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/common/cli_simple.c b/common/cli_simple.c index 7d91316a0fb..e80ba488a5e 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -60,13 +60,14 @@ int cli_simple_parse_line(char *line, char *argv[]) return nargs; } -void cli_simple_process_macros(const char *input, char *output) +int cli_simple_process_macros(const char *input, char *output, int max_size) { char c, prev; const char *varname_start = NULL; int inputcnt = strlen(input); - int outputcnt = CONFIG_SYS_CBSIZE; + int outputcnt = max_size; int state = 0; /* 0 = waiting for '$' */ + int ret; /* 1 = waiting for '(' or '{' */ /* 2 = waiting for ')' or '}' */ @@ -157,13 +158,18 @@ void cli_simple_process_macros(const char *input, char *output) prev = c; } - if (outputcnt) + ret = inputcnt ? -ENOSPC : 0; + if (outputcnt) { *output = 0; - else + } else { *(output - 1) = 0; + ret = -ENOSPC; + } debug_parser("[PROCESS_MACROS] OUTPUT len %zd: \"%s\"\n", strlen(output_start), output_start); + + return ret; } /* @@ -239,7 +245,8 @@ int cli_simple_run_command(const char *cmd, int flag) debug_parser("token: \"%s\"\n", token); /* find macros in this token and replace them */ - cli_simple_process_macros(token, finaltoken); + cli_simple_process_macros(token, finaltoken, + sizeof(finaltoken)); /* Extract arguments */ argc = cli_simple_parse_line(finaltoken, argv); |