[RFC PATCH v4 24/28] Modernize U-Boot shell

Francis Laniel
2022-06-16T22:37:05Z

From: Tom Rini <trini@konsulko.com>

On Fri, Apr 01, 2022 at 01:26:53AM +0200, Francis Laniel wrote:

> Hi.
>
> First I hope you are fine and the same for your relatives.
> I would also like to apologize for the delay between v2 and v3.
>
> During 2021 summer, Sean Anderson wrote a contribution to add a new shell, based
> on LIL, to U-Boot [1][2].
> While one of the goals of this contribution was to address the fact actual
> U-Boot shell, which is based on Busybox hush, is old there was a discussion
> about adding a new shell versus updating the actual one [3][4].
>
> So, in this series, with Harald Seiler, we updated the actual U-Boot shell to
> reflect what is currently in Busybox source code.
> Basically, this contribution is about taking a snapshot of Busybox shell/hush.c
> file (as it exists in commit 37460f5da) and adapt it to suit U-Boot needs.

In order to put this through CI and my local testing loop as well, I
need:
commit 0eae144ef84e7190b3c2da5fbd745468f7d1f7e6
Author: Tom Rini <trini@konsulko.com>
Date: Wed Apr 20 15:28:10 2022 -0400

HACK: Make new HUSH default

Signed-off-by: Tom Rini <trini@konsulko.com>

Signed-off-by: Francis Laniel <francis.laniel@amarulasolutions.com>
---
cmd/Kconfig | 2 +-
common/cli_hush_upstream.c | 5 +++--
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/cmd/Kconfig b/cmd/Kconfig
index ce19ad2080..32672d52ef 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -28,7 +28,6 @@ menu "Hush flavor to use"

config HUSH_OLD_PARSER
bool "Use hush old parser"
- default y
help
This option enables the old flavor of hush based on hush Busybox from
2005.
@@ -37,6 +36,7 @@ menu "Hush flavor to use"

config HUSH_2021_PARSER
bool "Use hush 2021 parser"
+ default y
help
This option enables the new flavor of hush based on hush Busybox from
2021.
diff --git a/common/cli_hush_upstream.c b/common/cli_hush_upstream.c
index 7b8712c981..9127183ed7 100644
--- a/common/cli_hush_upstream.c
+++ b/common/cli_hush_upstream.c
@@ -1454,6 +1454,7 @@ static void xxfree(void *ptr)
* HUSH_DEBUG >= 2 prints line number in this file where it was detected.
*/
#if HUSH_DEBUG < 2
+#include <linux/compiler.h>
# define msg_and_die_if_script(lineno, ...) msg_and_die_if_script(__VA_ARGS__)
# define syntax_error(lineno, msg) syntax_error(msg)
# define syntax_error_at(lineno, msg) syntax_error_at(msg)
@@ -1471,7 +1472,7 @@ static void die_if_script(void)
}
}

-static void msg_and_die_if_script(unsigned lineno, const char *fmt, ...)
+static void __maybe_unused msg_and_die_if_script(unsigned lineno, const char *fmt, ...)
{
va_list p;

@@ -1545,7 +1546,7 @@ static void syntax_error_unexpected_ch(unsigned lineno UNUSED_PARAM, int ch)
/* Replace each \x with x in place, return ptr past NUL. */
static char *unbackslash(char *src)
{
- char *dst = src = strchrnul(src, '\\');
+ char *dst = src = (char *)strchrnul(src, '\\');
while (1) {
if (*src == '\\') {
src++;
--
2.25.1