[PATCH 2/4] common: env: make use of isempty()

Marco Felsch m.felsch at pengutronix.de
Wed Mar 13 12:45:45 PDT 2024


Start making use of the new isempty() helper. No functional change.

Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
 common/env.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/env.c b/common/env.c
index d673b061ab7a..3ffde8bbd1dc 100644
--- a/common/env.c
+++ b/common/env.c
@@ -336,10 +336,10 @@ const char *getenv_nonempty(const char *var)
 {
 	const char *val = getenv(var);
 
-	if (val && *val)
-		return val;
+	if (isempty(val))
+		return NULL;
 
-	return NULL;
+	return val;
 }
 EXPORT_SYMBOL(getenv_nonempty);
 
@@ -347,7 +347,7 @@ int getenv_ull(const char *var , unsigned long long *val)
 {
 	const char *valstr = getenv(var);
 
-	if (!valstr || !*valstr)
+	if (isempty(valstr))
 		return -EINVAL;
 
 	*val = simple_strtoull(valstr, NULL, 0);
@@ -360,7 +360,7 @@ int getenv_ul(const char *var , unsigned long *val)
 {
 	const char *valstr = getenv(var);
 
-	if (!valstr || !*valstr)
+	if (isempty(valstr))
 		return -EINVAL;
 
 	*val = simple_strtoul(valstr, NULL, 0);
@@ -373,7 +373,7 @@ int getenv_uint(const char *var , unsigned int *val)
 {
 	const char *valstr = getenv(var);
 
-	if (!valstr || !*valstr)
+	if (isempty(valstr))
 		return -EINVAL;
 
 	*val = simple_strtoul(valstr, NULL, 0);
-- 
2.39.2




More information about the barebox mailing list