diff mbox series

[v3,07/13] env: Use better name for variable in env_get_f()

Message ID 20211017153638.29870-8-kabel@kernel.org
State Accepted
Commit d1bca8d2a18eb4a850c0ecbc9327eb3dfa5df5e1
Delegated to: Simon Glass
Headers show
Series env_get_char() removal and env_get_f() refactor | expand

Commit Message

Marek Behún Oct. 17, 2021, 3:36 p.m. UTC
From: Marek Behún <marek.behun@nic.cz>

The `nxt` variable actually points to the terminating null-byte of the
current env var, and the next env var is at `nxt + 1`, not `nxt`. So a
better name for this variable is `end`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 cmd/nvedit.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Simon Glass Oct. 21, 2021, 6:49 p.m. UTC | #1
From: Marek Behún <marek.behun@nic.cz>

The `nxt` variable actually points to the terminating null-byte of the
current env var, and the next env var is at `nxt + 1`, not `nxt`. So a
better name for this variable is `end`.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 cmd/nvedit.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index f395d2893a..5b1d4c2448 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -726,19 +726,19 @@  static const char *env_match(const char *p, const char *s1)
  */
 int env_get_f(const char *name, char *buf, unsigned len)
 {
-	const char *env, *p, *nxt;
+	const char *env, *p, *end;
 
 	if (gd->env_valid == ENV_INVALID)
 		env = (const char *)default_environment;
 	else
 		env = (const char *)gd->env_addr;
 
-	for (p = env; *p != '\0'; p = nxt + 1) {
+	for (p = env; *p != '\0'; p = end + 1) {
 		const char *value;
 		int n;
 
-		for (nxt = p; *nxt != '\0'; ++nxt)
-			if (nxt - env >= CONFIG_ENV_SIZE)
+		for (end = p; *end != '\0'; ++end)
+			if (end - env >= CONFIG_ENV_SIZE)
 				return -1;
 
 		value = env_match(p, name);