mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] common: misc: use isalnum macro instead of open-coding
@ 2024-11-26 15:13 Ahmad Fatoum
  0 siblings, 0 replies; only message in thread
From: Ahmad Fatoum @ 2024-11-26 15:13 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-11-26 15:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-26 15:13 [PATCH] common: misc: use isalnum macro instead of open-coding Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox