mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] common: misc: use isalnum macro instead of open-coding
Date: Tue, 26 Nov 2024 16:13:40 +0100	[thread overview]
Message-ID: <20241126151340.3620283-1-a.fatoum@pengutronix.de> (raw)

We sacrifice 256 bytes in barebox proper for a lookup table that is used
to optimize isalpha, isalnum and friends.

Let's make use of it by using isalnum instead of open-coding.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/misc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/misc.c b/common/misc.c
index 7e19797c2f99..0c883b76c1c2 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -11,6 +11,7 @@
 #include <globalvar.h>
 #include <environment.h>
 #include <led.h>
+#include <linux/ctype.h>
 #include <of.h>
 #include <restart.h>
 #include <poweroff.h>
@@ -155,8 +156,7 @@ static char *of_machine_compatible;
 static bool barebox_valid_ldh_char(char c)
 {
 	/* "LDH" -> "Letters, digits, hyphens", as per RFC 5890, Section 2.3.1 */
-	return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') ||
-	       (c >= '0' && c <= '9') || c == '-';
+	return isalnum(c) || c == '-';
 }
 
 bool barebox_hostname_is_valid(const char *s)
-- 
2.39.5




                 reply	other threads:[~2024-11-26 15:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20241126151340.3620283-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@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