mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
vsprintf.c: correct printing of a NULL device path
When printing '%pD' with a value of NULL we want to output '<NULL>'. But this requires copying to buf. Leave this to string16. A unit test is supplied which relies on EFI support in the sandbox. The development for EFI support in the sandbox is currently in branch u-boot-dm/efi-working. The branch lacks commit6ea8b580f0
("efi_loader: correct DeviceNodeToText for media types"). Ater rebasing the aforementioned branch on U-Boot v2018.01 and adding256060e425
and this patch the test is executed successfully. Fixes:256060e425
(vsprintf.c: add EFI device path printing) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
56672bf52e
commit
5f1ce1d4ca
2 changed files with 6 additions and 1 deletions
|
@ -300,8 +300,9 @@ static char *device_path_string(char *buf, char *end, void *dp, int field_width,
|
||||||
{
|
{
|
||||||
u16 *str;
|
u16 *str;
|
||||||
|
|
||||||
|
/* If dp == NULL output the string '<NULL>' */
|
||||||
if (!dp)
|
if (!dp)
|
||||||
return "<NULL>";
|
return string16(buf, end, dp, field_width, precision, flags);
|
||||||
|
|
||||||
str = efi_dp_str((struct efi_device_path *)dp);
|
str = efi_dp_str((struct efi_device_path *)dp);
|
||||||
if (!str)
|
if (!str)
|
||||||
|
|
|
@ -44,6 +44,10 @@ static void efi_ut_print(void)
|
||||||
|
|
||||||
snprintf(str, sizeof(str), "_%pD_", buf);
|
snprintf(str, sizeof(str), "_%pD_", buf);
|
||||||
assert(!strcmp("_/SD(3)_", str));
|
assert(!strcmp("_/SD(3)_", str));
|
||||||
|
|
||||||
|
/* NULL device path */
|
||||||
|
snprintf(str, sizeof(str), "_%pD_", NULL);
|
||||||
|
assert(!strcmp("_<NULL>_", str));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue