Re: [PATCH v2 09/10] efi/libstub: Add efi_snprintf() to construct wide strings
From: Vincent Mailhol
Date: Tue Sep 15 2026 - 13:15:16 EST
On 9/9/26 13:55, Ard Biesheuvel wrote:
> From: Ard Biesheuvel <ardb@xxxxxxxxxx>
>
> The native EFI character set is UTF-16 (or in practice, UCS-2).
> Implement efi_snprintf() to construct UTF-16 strings using printf style
> templates. This will be used in a subsequent patch to set the
> LoaderDevicePartUUID EFI variable.
>
> Link: https://lore.kernel.org/all/20260903-efi_stub_bli-v2-1-dbf7ba915117@xxxxxxxxxx/
> Signed-off-by: Ard Biesheuvel <ardb@xxxxxxxxxx>
> ---
> drivers/firmware/efi/libstub/efistub.h | 1 +
> drivers/firmware/efi/libstub/vsprintf.c | 11 +++++++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
> index 36056c624782..880c1d0c464b 100644
> --- a/drivers/firmware/efi/libstub/efistub.h
> +++ b/drivers/firmware/efi/libstub/efistub.h
> @@ -1084,6 +1084,7 @@ int efi_vsnprintf(efi_char16_t *buf, size_t size, const char *fmt, va_list ap,
> bool crlf);
>
> __printf(1, 2) int efi_printk(char const *fmt, ...);
> +__printf(3, 4) int efi_snprintf(efi_char16_t *buf, size_t size, const char *fmt, ...);
>
> void efi_free(unsigned long size, unsigned long addr);
> DEFINE_FREE(efi_pool, void *, if (_T) efi_bs_call(free_pool, _T));
> diff --git a/drivers/firmware/efi/libstub/vsprintf.c b/drivers/firmware/efi/libstub/vsprintf.c
> index 7f6b891a338a..34a19495dace 100644
> --- a/drivers/firmware/efi/libstub/vsprintf.c
> +++ b/drivers/firmware/efi/libstub/vsprintf.c
> @@ -509,3 +509,14 @@ int efi_vsnprintf(efi_char16_t *buf, size_t size, const char *fmt, va_list ap,
>
> return pos;
> }
> +
> +int efi_snprintf(efi_char16_t *buf, size_t size, const char *fmt, ...)
> +{
> + va_list args;
> + int i;
> +
> + va_start(args, fmt);
> + i = efi_vsnprintf(buf, size, fmt, args, false);
> + va_end(args);
> + return i;
checkpatch.pl is complaining about the use of spaces instead of tabulations:
WARNING: please, no spaces at the start of a line
#41: FILE: drivers/firmware/efi/libstub/vsprintf.c:515:
+ va_list args;$
WARNING: please, no spaces at the start of a line
#42: FILE: drivers/firmware/efi/libstub/vsprintf.c:516:
+ int i;$
WARNING: please, no spaces at the start of a line
#44: FILE: drivers/firmware/efi/libstub/vsprintf.c:518:
+ va_start(args, fmt);$
WARNING: please, no spaces at the start of a line
#45: FILE: drivers/firmware/efi/libstub/vsprintf.c:519:
+ i = efi_vsnprintf(buf, size, fmt, args, false);$
WARNING: please, no spaces at the start of a line
#46: FILE: drivers/firmware/efi/libstub/vsprintf.c:520:
+ va_end(args);$
WARNING: please, no spaces at the start of a line
#47: FILE: drivers/firmware/efi/libstub/vsprintf.c:521:
+ return i;$
> +}
Yours sincerely,
Vincent Mailhol