From 1a62d64c7de7e7de3facf221eb8408ddfb675cb8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 5 Nov 2020 10:33:47 -0700 Subject: cli: Support macro processing with a fixed-size buffer At present cli_simple_process_macros() requires that the caller provide an output buffer that is exactly CONFIG_SYS_CBSIZE bytes in length. This makes sense since it is designed to be used from the command line. But we also want to use it for bootargs substitution. Update the function to allow the caller to specify the buffer size. Also return an error if the buffer is exhausted. The caller can ignore that if preferred. Signed-off-by: Simon Glass --- include/cli.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/cli.h b/include/cli.h index 39b913743b..3449fa6ae7 100644 --- a/include/cli.h +++ b/include/cli.h @@ -34,8 +34,10 @@ int cli_simple_run_command(const char *cmd, int flag); * * @param input Input string possible containing $() / ${} vars * @param output Output string with $() / ${} vars expanded + * @param max_size Maximum size of @output (including terminator) + * @return 0 if OK, -ENOSPC if we ran out of space in @output */ -void cli_simple_process_macros(const char *input, char *output); +int cli_simple_process_macros(const char *input, char *output, int max_size); /** * cli_simple_run_command_list() - Execute a list of command -- cgit v1.2.3