Merge tag 'efi-2022-04-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
[platform/kernel/u-boot.git] / lib / vsprintf.c
index e634bd7..2c84649 100644 (file)
@@ -255,7 +255,7 @@ static char *number(char *buf, char *end, u64 num,
        return buf;
 }
 
-static char *string(char *buf, char *end, char *s, int field_width,
+static char *string(char *buf, char *end, const char *s, int field_width,
                int precision, int flags)
 {
        int len, i;
@@ -276,9 +276,8 @@ static char *string(char *buf, char *end, char *s, int field_width,
 }
 
 /* U-Boot uses UTF-16 strings in the EFI context only. */
-#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
-static char *string16(char *buf, char *end, u16 *s, int field_width,
-               int precision, int flags)
+static __maybe_unused char *string16(char *buf, char *end, u16 *s,
+                                    int field_width, int precision, int flags)
 {
        const u16 *str = s ? s : L"<NULL>";
        ssize_t i, len = utf16_strnlen(str, precision);
@@ -317,7 +316,6 @@ static char *device_path_string(char *buf, char *end, void *dp, int field_width,
        return buf;
 }
 #endif
-#endif
 
 static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width,
                                int precision, int flags)
@@ -389,12 +387,14 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
  *   %pUB:   01020304-0506-0708-090A-0B0C0D0E0F10
  *   %pUl:   04030201-0605-0807-090a-0b0c0d0e0f10
  *   %pUL:   04030201-0605-0807-090A-0B0C0D0E0F10
+ *   %pUs:   GUID text representation if known or fallback to %pUl
  */
 static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
                         int precision, int flags, const char *fmt)
 {
        char uuid[UUID_STR_LEN + 1];
        int str_format;
+       const char *str;
 
        switch (*(++fmt)) {
        case 'L':
@@ -406,6 +406,13 @@ static char *uuid_string(char *buf, char *end, u8 *addr, int field_width,
        case 'B':
                str_format = UUID_STR_FORMAT_STD | UUID_STR_UPPER_CASE;
                break;
+       case 's':
+               str = uuid_guid_get_str(addr);
+               if (str)
+                       return string(buf, end, str,
+                                     field_width, precision, flags);
+               str_format = UUID_STR_FORMAT_GUID;
+               break;
        default:
                str_format = UUID_STR_FORMAT_STD;
                break;
@@ -616,7 +623,8 @@ repeat:
 
                case 's':
 /* U-Boot uses UTF-16 strings in the EFI context only. */
-#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD)
+#if (CONFIG_IS_ENABLED(EFI_LOADER) || CONFIG_IS_ENABLED(EFI_APP)) && \
+       !defined(API_BUILD)
                        if (qualifier == 'l') {
                                str = string16(str, end, va_arg(args, u16 *),
                                               field_width, precision, flags);