mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] fastboot: print all variables only on getvar:all and not its prefixes
@ 2024-08-09 14:19 Ahmad Fatoum
  2024-08-09 14:19 ` [PATCH 2/3] fastboot: retire strcmp_l1 in favor of str_has_prefix Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2024-08-09 14:19 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

strcmp_l1 compares up to the length of the first arguments, i.e. it does
a prefix check. For this, the prefix, which is usually a string literal,
needs to be the first argument.

The check for getvar:all doesn't follow this with the result that all of

  fastboot getvar 'all'
  fastboot getvar 'al'
  fastboot getvar 'a'
  fastboot getvar ''

behave the same. This undocumented quirk is most likely unintended, so
let's replace this with an actual equality check.

Note that strcmp_l1 also does a NULL-ness check. This is safe to remove,
as explained in the follow-up commit.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 common/fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 532286703089..e85cc6d8aaf8 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -312,7 +312,7 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 
 	pr_debug("getvar: \"%s\"\n", cmd);
 
-	if (!strcmp_l1(cmd, "all")) {
+	if (!strcmp(cmd, "all")) {
 		list_for_each_entry(var, &fb->variables, list)
 			fastboot_tx_print(fb, FASTBOOT_MSG_INFO, "%s: %s",
 					  var->name, var->value);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-14  8:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-09 14:19 [PATCH 1/3] fastboot: print all variables only on getvar:all and not its prefixes Ahmad Fatoum
2024-08-09 14:19 ` [PATCH 2/3] fastboot: retire strcmp_l1 in favor of str_has_prefix Ahmad Fatoum
2024-08-09 14:19 ` [PATCH 3/3] fastboot: avoid console_countdown_abort for getvar request Ahmad Fatoum
2024-08-14  8:53 ` [PATCH 1/3] fastboot: print all variables only on getvar:all and not its prefixes Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox