diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-01-26 06:30:30 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-01-28 21:37:13 +0100 |
commit | 5f1ce1d4ca4decef688fe0dd71b11927d6a18845 (patch) | |
tree | e2f2673d1ca5c157fa8baddbc056a33c50aeeae1 | |
parent | 56672bf52ebf7b9d6de245f7a1bf56679a39093b (diff) | |
download | u-boot-5f1ce1d4ca4decef688fe0dd71b11927d6a18845.zip u-boot-5f1ce1d4ca4decef688fe0dd71b11927d6a18845.tar.gz u-boot-5f1ce1d4ca4decef688fe0dd71b11927d6a18845.tar.bz2 |
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 commit 6ea8b580f06b ("efi_loader:
correct DeviceNodeToText for media types"). Ater rebasing the aforementioned
branch on U-Boot v2018.01 and adding 256060e4257a2 and this patch the test
is executed successfully.
Fixes: 256060e4257a2 (vsprintf.c: add EFI device path printing)
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
-rw-r--r-- | lib/vsprintf.c | 3 | ||||
-rw-r--r-- | test/print_ut.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 226f4eb..5f7a5f1 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -300,8 +300,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) diff --git a/test/print_ut.c b/test/print_ut.c index 1aa68be..d8e9da8 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -44,6 +44,10 @@ static void efi_ut_print(void) snprintf(str, sizeof(str), "_%pD_", buf); assert(!strcmp("_/SD(3)_", str)); + + /* NULL device path */ + snprintf(str, sizeof(str), "_%pD_", NULL); + assert(!strcmp("_<NULL>_", str)); #endif } |