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
  2024-11-28  7:44 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [PATCH] common: misc: use isalnum macro instead of open-coding
  2024-11-26 15:13 [PATCH] common: misc: use isalnum macro instead of open-coding Ahmad Fatoum
@ 2024-11-28  7:44 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-11-28  7:44 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Tue, 26 Nov 2024 16:13:40 +0100, Ahmad Fatoum wrote:
> 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.
> 
> 

Applied, thanks!

[1/1] common: misc: use isalnum macro instead of open-coding
      https://git.pengutronix.de/cgit/barebox/commit/?id=643497d2b40a (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-28  7:44 UTC | newest]

Thread overview: 2+ messages (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
2024-11-28  7:44 ` Sascha Hauer

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