Message ID | 20171123215901.8992-1-xypron.glpk@gmx.de |
---|---|
State | Rejected, archived |
Delegated to: | Alexander Graf |
Headers | show |
Series | [U-Boot,v2,1/1] vsprintf.c: add EFI device path printing | expand |
Dear Heinrich, In message <20171123215901.8992-1-xypron.glpk@gmx.de> you wrote: > > +#ifdef CONFIG_EFI_LOADER > +static char *device_path_string(char *buf, char *end, void *dp, int field_width, > + int precision, int flags) > +{ > + u16 *str = efi_dp_str((struct efi_device_path *)dp); > + > + /* Do not silently ignore out of memory situation */ > + if (!str && dp) > + panic("efi_dp_str: out of memory"); > + > + buf = string16(buf, end, str, field_width, precision, flags); > + efi_free_pool(str); > + return buf; > +} I think this would be much clearer if you wrote: u16 *str; if (dp == NULL) return "<NULL>"; str = efi_dp_str((struct efi_device_path *)dp); if (str == NULL) panic("device_path_string(): out of memory"); buf = string16(buf, end, str, field_width, precision, flags); efi_free_pool(str); return buf; Thanks. Best regards, Wolfgang Denk
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index dd572d2868..1135817fd8 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -18,6 +18,7 @@ #include <common.h> #include <charset.h> +#include <efi_loader.h> #include <uuid.h> #include <div64.h> @@ -292,6 +293,22 @@ static char *string16(char *buf, char *end, u16 *s, int field_width, return buf; } +#ifdef CONFIG_EFI_LOADER +static char *device_path_string(char *buf, char *end, void *dp, int field_width, + int precision, int flags) +{ + u16 *str = efi_dp_str((struct efi_device_path *)dp); + + /* Do not silently ignore out of memory situation */ + if (!str && dp) + panic("efi_dp_str: out of memory"); + + buf = string16(buf, end, str, field_width, precision, flags); + efi_free_pool(str); + return buf; +} +#endif + #ifdef CONFIG_CMD_NET static const char hex_asc[] = "0123456789abcdef"; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] @@ -435,6 +452,11 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, #endif switch (*fmt) { +#ifdef CONFIG_EFI_LOADER + case 'D': + return device_path_string(buf, end, ptr, field_width, + precision, flags); +#endif #ifdef CONFIG_CMD_NET case 'a': flags |= SPECIAL | ZEROPAD;
For debugging efi_loader we need the capability to print EFI device paths. With this patch we can write: debug("device path: %pD", dp); A possible output would be device path: /MemoryMapped(0x0,0x3ff93a82,0x3ff93a82) Cc: Wolfgang Denk <wd@denx.de> Suggested-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- I propose Alex picks up this patch for the EFI tree. v2 Panic if out of memory. Wolfgang suggested not to silently ignore an out of memory situation. --- lib/vsprintf.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+), 0 deletion(-)