diff mbox series

bootflow: Allow setting a cmdline arg with no value

Message ID 20231129103119.1.I183c8602567828319b4677b66c6e67151dc97773@changeid
State Accepted
Commit 921f63e5723880bbbaf65429564e5638b7bbd002
Delegated to: Tom Rini
Headers show
Series bootflow: Allow setting a cmdline arg with no value | expand

Commit Message

Simon Glass Nov. 29, 2023, 5:31 p.m. UTC
This is supposed to be supported by the 'bootflow cmd' command, at
least according to the help. There is a 'bootflow cmd clear' but it is
often more intuitive to use 'bootcmd cmd set' with an empty value.

Update the command to pass BOOTFLOWCL_EMPTY in this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 cmd/bootflow.c       | 4 ++--
 test/boot/bootflow.c | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Tom Rini Dec. 20, 2023, 9:01 p.m. UTC | #1
On Wed, Nov 29, 2023 at 10:31:19AM -0700, Simon Glass wrote:

> This is supposed to be supported by the 'bootflow cmd' command, at
> least according to the help. There is a 'bootflow cmd clear' but it is
> often more intuitive to use 'bootcmd cmd set' with an empty value.
> 
> Update the command to pass BOOTFLOWCL_EMPTY in this case.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 3aeb40d690f..c6aa06b9ce9 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -524,9 +524,9 @@  static int do_bootflow_cmdline(struct cmd_tbl *cmdtp, int flag, int argc,
 	op = argv[1];
 	arg = argv[2];
 	if (*op == 's') {
-		if (argc < 4)
+		if (argc < 3)
 			return CMD_RET_USAGE;
-		val = argv[3];
+		val = argv[3] ?: (const char *)BOOTFLOWCL_EMPTY;
 	}
 
 	switch (*op) {
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index b97c566f000..43cba3cc783 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -1013,6 +1013,10 @@  static int bootflow_cmdline(struct unit_test_state *uts)
 	ut_asserteq(0, run_command("bootflow cmdline get mary", 0));
 	ut_assert_nextline_empty();
 
+	ut_asserteq(0, run_command("bootflow cmdline set mary abc", 0));
+	ut_asserteq(0, run_command("bootflow cmdline set mary", 0));
+	ut_assert_nextline_empty();
+
 	ut_assert_console_end();
 
 	return 0;