From 4c7363068651f222be6150050bb3aa9823ca6f78 Mon Sep 17 00:00:00 2001 From: Massimiliano Minella Date: Thu, 8 Feb 2024 15:58:27 +0100 Subject: cmd: setexpr: fix no matching string in gsub return empty value In gsub, when the destination string is empty, the string 't' is provided and the regular expression doesn't match, then the final result is an empty string. Example: => echo ${foo} => setenv foo => setexpr foo gsub e a bar => echo ${foo} => The variable ${foo} should contain "bar" and the lack of match shouldn't be considered an error. This patch fixes the erroneous behavior by removing the return statement and breaking out of the loop in case of lack of match. Also add a test for the no match case. Signed-off-by: Massimiliano Minella --- doc/usage/cmd/setexpr.rst | 1 + 1 file changed, 1 insertion(+) (limited to 'doc/usage/cmd') diff --git a/doc/usage/cmd/setexpr.rst b/doc/usage/cmd/setexpr.rst index d245a13ca88..593a0ea91e1 100644 --- a/doc/usage/cmd/setexpr.rst +++ b/doc/usage/cmd/setexpr.rst @@ -39,6 +39,7 @@ setexpr name gsub [] string , substitute the string . The result is assigned to . If is not supplied, use the old value of . + If no substring matching is found in , assign to . setexpr name sub [] Just like gsub(), but replace only the first matching substring -- cgit v1.3.1 From 9a6e975c7c41f2fb67d7ef11fceb28942a4a4b4c Mon Sep 17 00:00:00 2001 From: Weizhao Ouyang Date: Mon, 4 Mar 2024 14:42:42 +0000 Subject: cmd: rng: Add rng list command The 'rng list' command probes all RNG devices and list those devices that are successfully probed. Also update the help info. Reviewed-by: Heinrich Schuchardt Signed-off-by: Weizhao Ouyang --- cmd/rng.c | 23 ++++++++++++++++++----- doc/usage/cmd/rng.rst | 14 ++++++++++---- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'doc/usage/cmd') diff --git a/cmd/rng.c b/cmd/rng.c index 52f722c7af8..b073a6c8492 100644 --- a/cmd/rng.c +++ b/cmd/rng.c @@ -19,6 +19,22 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) struct udevice *dev; int ret = CMD_RET_SUCCESS; + if (argc == 2 && !strcmp(argv[1], "list")) { + int idx = 0; + + uclass_foreach_dev_probe(UCLASS_RNG, dev) { + idx++; + printf("RNG #%d - %s\n", dev->seq_, dev->name); + } + + if (!idx) { + log_err("No RNG device\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; + } + switch (argc) { case 1: devnum = 0; @@ -56,12 +72,9 @@ static int do_rng(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return ret; } -U_BOOT_LONGHELP(rng, - "[dev [n]]\n" - " - print n random bytes(max 64) read from dev\n"); - U_BOOT_CMD( rng, 3, 0, do_rng, "print bytes from the hardware random number generator", - rng_help_text + "list - list all the probed rng devices\n" + "rng [dev] [n] - print n random bytes(max 64) read from dev\n" ); diff --git a/doc/usage/cmd/rng.rst b/doc/usage/cmd/rng.rst index 274e4d88df3..4a61e33d272 100644 --- a/doc/usage/cmd/rng.rst +++ b/doc/usage/cmd/rng.rst @@ -11,16 +11,22 @@ Synopsis :: - rng [devnum [n]] + rng list + rng [dev] [n] -Description ------------ +rng list +-------- + +List all the probed rng devices. + +rng [dev] [n] +------------- The *rng* command reads the random number generator(RNG) device and prints the random bytes read on the console. A maximum of 64 bytes can be read in one invocation of the command. -devnum +dev The RNG device from which the random bytes are to be read. Defaults to 0. -- cgit v1.3.1 From 884785adc1dc5e7b91acb542ba83941951ff2b77 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 16 Mar 2024 11:09:36 +0100 Subject: doc: typo Synopis %s/Synopis/Synopsis/g Signed-off-by: Heinrich Schuchardt --- doc/usage/cmd/acpi.rst | 4 ++-- doc/usage/cmd/bootdev.rst | 4 ++-- doc/usage/cmd/bootflow.rst | 4 ++-- doc/usage/cmd/bootmeth.rst | 4 ++-- doc/usage/cmd/cbsysinfo.rst | 4 ++-- doc/usage/cmd/cedit.rst | 4 ++-- doc/usage/cmd/cli.rst | 4 ++-- doc/usage/cmd/dm.rst | 4 ++-- doc/usage/cmd/fdt.rst | 4 ++-- doc/usage/cmd/font.rst | 4 ++-- doc/usage/cmd/for.rst | 4 ++-- doc/usage/cmd/history.rst | 4 ++-- doc/usage/cmd/host.rst | 4 ++-- doc/usage/cmd/md.rst | 4 ++-- doc/usage/cmd/mtrr.rst | 4 ++-- doc/usage/cmd/panic.rst | 4 ++-- doc/usage/cmd/part.rst | 4 ++-- doc/usage/cmd/sf.rst | 4 ++-- doc/usage/cmd/sm.rst | 4 ++-- doc/usage/cmd/trace.rst | 4 ++-- doc/usage/cmd/ut.rst | 4 ++-- 21 files changed, 42 insertions(+), 42 deletions(-) (limited to 'doc/usage/cmd') diff --git a/doc/usage/cmd/acpi.rst b/doc/usage/cmd/acpi.rst index a630f1ec5e3..9f30972fe53 100644 --- a/doc/usage/cmd/acpi.rst +++ b/doc/usage/cmd/acpi.rst @@ -6,8 +6,8 @@ acpi command ============ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/bootdev.rst b/doc/usage/cmd/bootdev.rst index 658020e7c7f..f759abab354 100644 --- a/doc/usage/cmd/bootdev.rst +++ b/doc/usage/cmd/bootdev.rst @@ -6,8 +6,8 @@ bootdev command =============== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/bootflow.rst b/doc/usage/cmd/bootflow.rst index 16ba986dc8a..6519e4880a9 100644 --- a/doc/usage/cmd/bootflow.rst +++ b/doc/usage/cmd/bootflow.rst @@ -6,8 +6,8 @@ bootflow command ================ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/bootmeth.rst b/doc/usage/cmd/bootmeth.rst index 95651fdc7c5..2903977ee54 100644 --- a/doc/usage/cmd/bootmeth.rst +++ b/doc/usage/cmd/bootmeth.rst @@ -6,8 +6,8 @@ bootmeth command ================ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/cbsysinfo.rst b/doc/usage/cmd/cbsysinfo.rst index 8c03a85169d..80d8ba1b662 100644 --- a/doc/usage/cmd/cbsysinfo.rst +++ b/doc/usage/cmd/cbsysinfo.rst @@ -3,8 +3,8 @@ cbsysinfo ========= -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/cedit.rst b/doc/usage/cmd/cedit.rst index b39d708281d..5670805a00e 100644 --- a/doc/usage/cmd/cedit.rst +++ b/doc/usage/cmd/cedit.rst @@ -6,8 +6,8 @@ cedit command ============= -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/cli.rst b/doc/usage/cmd/cli.rst index 81487722f69..23e5ee7a902 100644 --- a/doc/usage/cmd/cli.rst +++ b/doc/usage/cmd/cli.rst @@ -6,8 +6,8 @@ cli command =========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/dm.rst b/doc/usage/cmd/dm.rst index 9bef2eeaed8..7651507937a 100644 --- a/doc/usage/cmd/dm.rst +++ b/doc/usage/cmd/dm.rst @@ -6,8 +6,8 @@ dm command ========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/fdt.rst b/doc/usage/cmd/fdt.rst index 3e8c32cdea3..71a9fc627e5 100644 --- a/doc/usage/cmd/fdt.rst +++ b/doc/usage/cmd/fdt.rst @@ -6,8 +6,8 @@ fdt command =========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/font.rst b/doc/usage/cmd/font.rst index adcd5126d0a..a8782546333 100644 --- a/doc/usage/cmd/font.rst +++ b/doc/usage/cmd/font.rst @@ -6,8 +6,8 @@ font command ============ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/for.rst b/doc/usage/cmd/for.rst index 4c98419b28f..729bd4db43c 100644 --- a/doc/usage/cmd/for.rst +++ b/doc/usage/cmd/for.rst @@ -4,8 +4,8 @@ for command =========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/history.rst b/doc/usage/cmd/history.rst index 564a1596655..b52b5b220ae 100644 --- a/doc/usage/cmd/history.rst +++ b/doc/usage/cmd/history.rst @@ -6,8 +6,8 @@ history command =============== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/host.rst b/doc/usage/cmd/host.rst index 072497db903..a70a432b6f2 100644 --- a/doc/usage/cmd/host.rst +++ b/doc/usage/cmd/host.rst @@ -6,8 +6,8 @@ host command ============ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/md.rst b/doc/usage/cmd/md.rst index 9ea148a8dca..9a9919f9ad0 100644 --- a/doc/usage/cmd/md.rst +++ b/doc/usage/cmd/md.rst @@ -6,8 +6,8 @@ md command ========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/mtrr.rst b/doc/usage/cmd/mtrr.rst index c65618950bc..3c5c3ba3d43 100644 --- a/doc/usage/cmd/mtrr.rst +++ b/doc/usage/cmd/mtrr.rst @@ -6,8 +6,8 @@ mtrr command ============ -Synopis -------- +Synopsis +-------- mtrr [list] mtrr set diff --git a/doc/usage/cmd/panic.rst b/doc/usage/cmd/panic.rst index ba5ea626108..39d32adbc99 100644 --- a/doc/usage/cmd/panic.rst +++ b/doc/usage/cmd/panic.rst @@ -6,8 +6,8 @@ panic command ============= -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst index 58be38781e3..e7faeccbb09 100644 --- a/doc/usage/cmd/part.rst +++ b/doc/usage/cmd/part.rst @@ -6,8 +6,8 @@ part command ============ -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/sf.rst b/doc/usage/cmd/sf.rst index 24d5dc692db..dfdca46e66c 100644 --- a/doc/usage/cmd/sf.rst +++ b/doc/usage/cmd/sf.rst @@ -6,8 +6,8 @@ sf command ========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/sm.rst b/doc/usage/cmd/sm.rst index b767647d772..e828fddc519 100644 --- a/doc/usage/cmd/sm.rst +++ b/doc/usage/cmd/sm.rst @@ -6,8 +6,8 @@ sm command ========== -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/trace.rst b/doc/usage/cmd/trace.rst index ad6db123942..e798b2bbc6b 100644 --- a/doc/usage/cmd/trace.rst +++ b/doc/usage/cmd/trace.rst @@ -6,8 +6,8 @@ trace command ============= -Synopis -------- +Synopsis +-------- :: diff --git a/doc/usage/cmd/ut.rst b/doc/usage/cmd/ut.rst index ddc48ec42dd..45bc9ffbdc5 100644 --- a/doc/usage/cmd/ut.rst +++ b/doc/usage/cmd/ut.rst @@ -6,8 +6,8 @@ ut command ========== -Synopis -------- +Synopsis +-------- :: -- cgit v1.3.1