diff options
author | Tom Rini <trini@konsulko.com> | 2023-03-31 10:04:23 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-03-31 10:04:23 -0400 |
commit | b8deed53fe6a55ef76b4f9038bb419a9c853a9fa (patch) | |
tree | 2f0cdb8f35d7c51611417bab680583a65bf21306 /common/cli.c | |
parent | f1617e99b933d2c3ecb381954148284d37bf922e (diff) | |
parent | f98b112f9e0516fc9333611d1228d0b634aa353e (diff) |
Merge branch '2023-03-30-assorted-general-upates' into next
- RTC cleanups / improvements, run_commandf() cleanups, fs bugfixes,
socrates config fix, PCI MPS support, GPIO improvements, other code
cleanups
Diffstat (limited to 'common/cli.c')
-rw-r--r-- | common/cli.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/common/cli.c b/common/cli.c index 9451e6a1426..3916a7b10a7 100644 --- a/common/cli.c +++ b/common/cli.c @@ -8,6 +8,8 @@ * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com> */ +#define pr_fmt(fmt) "cli: %s: " fmt, __func__ + #include <common.h> #include <bootstage.h> #include <cli.h> @@ -20,6 +22,7 @@ #include <malloc.h> #include <asm/global_data.h> #include <dm/ofnode.h> +#include <linux/errno.h> #ifdef CONFIG_CMDLINE /* @@ -129,16 +132,26 @@ int run_command_list(const char *cmd, int len, int flag) int run_commandf(const char *fmt, ...) { va_list args; - char cmd[128]; - int i, ret; + int nbytes; va_start(args, fmt); - i = vsnprintf(cmd, sizeof(cmd), fmt, args); + /* + * Limit the console_buffer space being used to CONFIG_SYS_CBSIZE, + * because its last byte is used to fit the replacement of \0 by \n\0 + * in underlying hush parser + */ + nbytes = vsnprintf(console_buffer, CONFIG_SYS_CBSIZE, fmt, args); va_end(args); - ret = run_command(cmd, 0); - - return ret; + if (nbytes < 0) { + pr_debug("I/O internal error occurred.\n"); + return -EIO; + } else if (nbytes >= CONFIG_SYS_CBSIZE) { + pr_debug("'fmt' size:%d exceeds the limit(%d)\n", + nbytes, CONFIG_SYS_CBSIZE); + return -ENOSPC; + } + return run_command(console_buffer, 0); } /****************************************************************************/ |