From: Hanyuan Zhao Date: Tue, 5 Mar 2024 07:37:33 +0000 (+0800) Subject: cli: panic when failed to allocate memory for the history buffer X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=44951340309d0dca73c05fc61406a1e839d1da93;p=u-boot.git cli: panic when failed to allocate memory for the history buffer This commit simply modifies the history initialize function, replacing the return value by panic with reasons. The calling chains of hist_init don't have steps explicitly throwing or dealing with the ENOMEM error, and once the init fails, the whole system is died. Using panic here to provide error information instead. Signed-off-by: Hanyuan Zhao --- diff --git a/common/cli_readline.c b/common/cli_readline.c index 2507be2295..99e7efdfe5 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -110,7 +110,7 @@ static int hist_init(void) hist = calloc(HIST_MAX, HIST_SIZE + 1); if (!hist) - return -ENOMEM; + panic("%s: calloc: out of memory!\n", __func__); for (i = 0; i < HIST_MAX; i++) hist_list[i] = hist + (i * (HIST_SIZE + 1));