mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/4] common: env: make use of isempty()
Date: Wed, 13 Mar 2024 20:45:45 +0100	[thread overview]
Message-ID: <20240313194547.3725723-2-m.felsch@pengutronix.de> (raw)
In-Reply-To: <20240313194547.3725723-1-m.felsch@pengutronix.de>

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

Signed-off-by: Marco Felsch <m.felsch@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




  reply	other threads:[~2024-03-13 19:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-13 19:45 [PATCH 1/4] string: add isempty helper Marco Felsch
2024-03-13 19:45 ` Marco Felsch [this message]
2024-03-13 19:45 ` [PATCH 3/4] common: hostname: validate the provided hostname Marco Felsch
2024-03-13 19:45 ` [PATCH 4/4] bootm: add global.bootm.provide_hostname option Marco Felsch
2024-03-14  6:15   ` Ahmad Fatoum
2024-03-20 10:48     ` Marco Felsch
2024-04-04 13:40 ` [PATCH 1/4] string: add isempty helper Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240313194547.3725723-2-m.felsch@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox