Skip to contentSkip to conversation

cli_hush.c: remove broken sanity check

PATCH New Rasmus Villemoes 2 participants 2 messages Oct 7, 2020 – Oct 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cli_hush.c: remove broken sanity check

This code is intended do prevent one from setting a shell variable abc by doing

abc=123

if an environment variable named abc already exists. However, the check is broken, since the env_get is done before the split on =, so we look up whether an environment variable "abc=123" exists, which is obviously never the case.

One could move the code to below the split on =, but instead, just remove it, saving a little .text: The check has never worked as intended (it goes all the way back to the initial git commit), and it would anyway not guard against one first setting the shell variable, then doing 'env set abc xyz'.

---
 common/cli_hush.c | 8 --------
 1 file changed, 8 deletions(-)
common/cli_hush.c +0 -8
index 5b1f119074..66995c255b 100644
@@ -2170,14 +2170,6 @@ int set_local_var(const char *s, int flg_export)
 
 	name=strdup(s);
 
-#ifdef __U_BOOT__
-	if (env_get(name) != NULL) {
-		printf ("ERROR: "
-				"There is a global environment variable with the same name.\n");
-		free(name);
-		return -1;
-	}
-#endif
 	/* Assume when we enter this function that we are already in
 	 * NAME=VALUE format.  So the first order of business is to
 	 * split 's' on the '=' into 'name' and 'value' */
Signature · 1 line
2.23.0
#1 lore raw

PATCH 1/1 cli_hush.c: remove broken sanity check

Quoted 10 lines · Rasmus Villemoes

This code is intended do prevent one from setting a shell variable abc by doing

abc=123

if an environment variable named abc already exists. However, the check is broken, since the env_get is done before the split on =, so we look up whether an environment variable "abc=123" exists, which is obviously never the case.

Quoted 7 lines

One could move the code to below the split on =, but instead, just remove it, saving a little .text: The check has never worked as intended (it goes all the way back to the initial git commit), and it would anyway not guard against one first setting the shell variable, then doing 'env set abc xyz'.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/8eee70c9/attachment.sig>