[PATCH] var: Remove unset check in varnull

Herbert Xu <[email protected]> Sat, 13 Jun 2026 13:15:05 +0800
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Unset variables always carry two NUL characters at the end so it's
safe to call strchrnul in varnull uncondtionally and step past the
first NUL character.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/src/var.c b/src/var.c
index 6e0671a..90fc896 100644
--- a/src/var.c
+++ b/src/var.c
@@ -156,7 +156,8 @@ RESET {
 
 static char *varnull(const char *s)
 {
-	return (strchr(s, '=') ?: nullstr - 1) + 1;
+	/* Unset variables always end with two NUL chars. */
+	return strchrnul(s, '=') + 1;
 }
 
 /*
-- 
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt