Commit 1d43bfd2d54240c18ec6bfd68a57349cae839f13
Committed by
Tom Rini
1 parent
73671dad49
Exists in
v2017.01-smarct4x
and in
41 other branches
Add run_command_repeatable()
run_command() returns 0 on success and 1 on error. However, there are some invocations which expect 0 or 1 for success (not repeatable or repeatable) and -1 for error; add run_command_repeatable() for this purpose. Signed-off-by: Thomas Betker <thomas.betker@rohde-schwarz.com> Acked-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
Showing 2 changed files with 25 additions and 0 deletions Side-by-side Diff
common/cli.c
... | ... | @@ -41,6 +41,30 @@ |
41 | 41 | #endif |
42 | 42 | } |
43 | 43 | |
44 | +/* | |
45 | + * Run a command using the selected parser, and check if it is repeatable. | |
46 | + * | |
47 | + * @param cmd Command to run | |
48 | + * @param flag Execution flags (CMD_FLAG_...) | |
49 | + * @return 0 (not repeatable) or 1 (repeatable) on success, -1 on error. | |
50 | + */ | |
51 | +int run_command_repeatable(const char *cmd, int flag) | |
52 | +{ | |
53 | +#ifndef CONFIG_SYS_HUSH_PARSER | |
54 | + return cli_simple_run_command(cmd, flag); | |
55 | +#else | |
56 | + /* | |
57 | + * parse_string_outer() returns 1 for failure, so clean up | |
58 | + * its result. | |
59 | + */ | |
60 | + if (parse_string_outer(cmd, | |
61 | + FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP)) | |
62 | + return -1; | |
63 | + | |
64 | + return 0; | |
65 | +#endif | |
66 | +} | |
67 | + | |
44 | 68 | int run_command_list(const char *cmd, int len, int flag) |
45 | 69 | { |
46 | 70 | int need_buff = 1; |
include/common.h