[PATCH] common: misc: use isalnum macro instead of open-coding
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Nov 26 07:13:40 PST 2024
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 at 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
More information about the barebox
mailing list