summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
authorArvind Sankar <nivedita@alum.mit.edu>2020-05-18 15:07:02 -0400
committerArd Biesheuvel <ardb@kernel.org>2020-05-19 10:31:25 +0200
commit7c30fd79168aeb83d11260246d93f8a293052007 (patch)
tree3337f0d5a9fbc1a571d90a85da00170fa3b6bd8e /drivers/firmware
parent77e48db04a02ebd00229281c26575979b0b465e0 (diff)
efi/printf: Merge 'p' with the integer formats
Treat 'p' as a hexadecimal integer with precision equal to the number of digits in void *. Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu> Link: https://lore.kernel.org/r/20200518190716.751506-11-nivedita@alum.mit.edu Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efi/libstub/vsprintf.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/firmware/efi/libstub/vsprintf.c b/drivers/firmware/efi/libstub/vsprintf.c
index 00123d5f402f..b7316ab9f8b4 100644
--- a/drivers/firmware/efi/libstub/vsprintf.c
+++ b/drivers/firmware/efi/libstub/vsprintf.c
@@ -297,9 +297,6 @@ int vsprintf(char *buf, const char *fmt, va_list args)
}
}
- /* default base */
- base = 10;
-
switch (*fmt) {
case 'c':
if (!(flags & LEFT))
@@ -323,21 +320,15 @@ int vsprintf(char *buf, const char *fmt, va_list args)
*str++ = ' ';
continue;
- case 'p':
- if (field_width == -1) {
- field_width = 2 * sizeof(void *);
- flags |= ZEROPAD;
- }
- str = number(str,
- (unsigned long)va_arg(args, void *), 16,
- field_width, precision, flags);
- continue;
-
/* integer number formats - set up the flags and "break" */
case 'o':
base = 8;
break;
+ case 'p':
+ if (precision < 0)
+ precision = 2 * sizeof(void *);
+ fallthrough;
case 'x':
flags |= SMALL;
fallthrough;
@@ -350,6 +341,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
flags |= SIGN;
fallthrough;
case 'u':
+ base = 10;
break;
default:
@@ -360,7 +352,9 @@ int vsprintf(char *buf, const char *fmt, va_list args)
--fmt;
continue;
}
- if (flags & SIGN) {
+ if (*fmt == 'p') {
+ num = (unsigned long)va_arg(args, void *);
+ } else if (flags & SIGN) {
switch (qualifier) {
case 'L':
num = va_arg(args, long long);