]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cli: panic when failed to allocate memory for the history buffer
authorHanyuan Zhao <hanyuan-z@qq.com>
Tue, 5 Mar 2024 07:37:33 +0000 (15:37 +0800)
committerTom Rini <trini@konsulko.com>
Wed, 13 Mar 2024 16:40:43 +0000 (12:40 -0400)
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 <hanyuan-z@qq.com>
common/cli_readline.c

index 2507be2295269a64b9eefe50ba4572c5e4111337..99e7efdfe55553b78f181949433ef97aeb179ce9 100644 (file)
@@ -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));