]> git.sur5r.net Git - u-boot/blobdiff - lib/vsprintf.c
lib: Add hexdump
[u-boot] / lib / vsprintf.c
index 226f4eb3e5125878200fbeb1109d3ab24e41e260..8b1b29fb5aa75278762a4c1222481fb42c0855c3 100644 (file)
@@ -15,6 +15,7 @@
 #include <charset.h>
 #include <efi_loader.h>
 #include <div64.h>
+#include <hexdump.h>
 #include <uuid.h>
 #include <stdarg.h>
 #include <linux/ctype.h>
@@ -300,8 +301,9 @@ static char *device_path_string(char *buf, char *end, void *dp, int field_width,
 {
        u16 *str;
 
+       /* If dp == NULL output the string '<NULL>' */
        if (!dp)
-               return "<NULL>";
+               return string16(buf, end, dp, field_width, precision, flags);
 
        str = efi_dp_str((struct efi_device_path *)dp);
        if (!str)
@@ -314,17 +316,6 @@ static char *device_path_string(char *buf, char *end, void *dp, int field_width,
 #endif
 
 #ifdef CONFIG_CMD_NET
-static const char hex_asc[] = "0123456789abcdef";
-#define hex_asc_lo(x)  hex_asc[((x) & 0x0f)]
-#define hex_asc_hi(x)  hex_asc[((x) & 0xf0) >> 4]
-
-static inline char *pack_hex_byte(char *buf, u8 byte)
-{
-       *buf++ = hex_asc_hi(byte);
-       *buf++ = hex_asc_lo(byte);
-       return buf;
-}
-
 static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
                                int precision, int flags)
 {
@@ -334,7 +325,7 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
        int i;
 
        for (i = 0; i < 6; i++) {
-               p = pack_hex_byte(p, addr[i]);
+               p = hex_byte_pack(p, addr[i]);
                if (!(flags & SPECIAL) && i != 5)
                        *p++ = ':';
        }
@@ -353,8 +344,8 @@ static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width,
        int i;
 
        for (i = 0; i < 8; i++) {
-               p = pack_hex_byte(p, addr[2 * i]);
-               p = pack_hex_byte(p, addr[2 * i + 1]);
+               p = hex_byte_pack(p, addr[2 * i]);
+               p = hex_byte_pack(p, addr[2 * i + 1]);
                if (!(flags & SPECIAL) && i != 7)
                        *p++ = ':';
        }
@@ -782,6 +773,7 @@ int sprintf(char *buf, const char *fmt, ...)
        return i;
 }
 
+#if CONFIG_IS_ENABLED(PRINTF)
 int printf(const char *fmt, ...)
 {
        va_list args;
@@ -823,15 +815,7 @@ int vprintf(const char *fmt, va_list args)
        puts(printbuffer);
        return i;
 }
-
-
-void __assert_fail(const char *assertion, const char *file, unsigned line,
-                  const char *function)
-{
-       /* This will not return */
-       panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
-             assertion);
-}
+#endif
 
 char *simple_itoa(ulong i)
 {