Re: [PATCH v2 3/7] include: hexdump: make hex2bin() usable from host tools

Heinrich Schuchardt xypron.glpk at gmx.de
Thu Apr 16 13:00:31 CEST 2026


Am 16. April 2026 03:46:42 MESZ schrieb Daniel Golle <daniel at makrotopia.org>:
>Make hexdump.h work in host-tool builds by using 'uint8_t' instead
>of 'u8', and including either user-space libc <ctype.h> for host-tools
>or <linux/ctype.h> when building U-Boot itself.
>
>Signed-off-by: Daniel Golle <daniel at makrotopia.org>
>---
>v2: new patch
>
> include/hexdump.h | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
>diff --git a/include/hexdump.h b/include/hexdump.h
>index f2ca4793d69..5cb48d79efe 100644
>--- a/include/hexdump.h
>+++ b/include/hexdump.h
>@@ -7,7 +7,11 @@
> #ifndef HEXDUMP_H
> #define HEXDUMP_H
> 
>+#ifdef USE_HOSTCC
>+#include <ctype.h>
>+#else
> #include <linux/ctype.h>

uin8_t is defined in stdint.h.
Don't we need it in the HOSTCC case?

Best regards 

Heinrich


>+#endif
> #include <linux/types.h>
> 
> enum dump_prefix_t {
>@@ -20,7 +24,7 @@ extern const char hex_asc[];
> #define hex_asc_lo(x)	hex_asc[((x) & 0x0f)]
> #define hex_asc_hi(x)	hex_asc[((x) & 0xf0) >> 4]
> 
>-static inline char *hex_byte_pack(char *buf, u8 byte)
>+static inline char *hex_byte_pack(char *buf, uint8_t byte)
> {
> 	*buf++ = hex_asc_hi(byte);
> 	*buf++ = hex_asc_lo(byte);
>@@ -52,7 +56,7 @@ static inline int hex_to_bin(char ch)
>  *
>  * Return 0 on success, -1 in case of bad input.
>  */
>-static inline int hex2bin(u8 *dst, const char *src, size_t count)
>+static inline int hex2bin(uint8_t *dst, const char *src, size_t count)
> {
> 	while (count--) {
> 		int hi = hex_to_bin(*src++);



More information about the U-Boot mailing list