Commit 7c30fd79 authored by Arvind Sankar's avatar Arvind Sankar Committed by Ard Biesheuvel

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: default avatarArvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200518190716.751506-11-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 77e48db0
...@@ -297,9 +297,6 @@ int vsprintf(char *buf, const char *fmt, va_list args) ...@@ -297,9 +297,6 @@ int vsprintf(char *buf, const char *fmt, va_list args)
} }
} }
/* default base */
base = 10;
switch (*fmt) { switch (*fmt) {
case 'c': case 'c':
if (!(flags & LEFT)) if (!(flags & LEFT))
...@@ -323,21 +320,15 @@ int vsprintf(char *buf, const char *fmt, va_list args) ...@@ -323,21 +320,15 @@ int vsprintf(char *buf, const char *fmt, va_list args)
*str++ = ' '; *str++ = ' ';
continue; 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" */ /* integer number formats - set up the flags and "break" */
case 'o': case 'o':
base = 8; base = 8;
break; break;
case 'p':
if (precision < 0)
precision = 2 * sizeof(void *);
fallthrough;
case 'x': case 'x':
flags |= SMALL; flags |= SMALL;
fallthrough; fallthrough;
...@@ -350,6 +341,7 @@ int vsprintf(char *buf, const char *fmt, va_list args) ...@@ -350,6 +341,7 @@ int vsprintf(char *buf, const char *fmt, va_list args)
flags |= SIGN; flags |= SIGN;
fallthrough; fallthrough;
case 'u': case 'u':
base = 10;
break; break;
default: default:
...@@ -360,7 +352,9 @@ int vsprintf(char *buf, const char *fmt, va_list args) ...@@ -360,7 +352,9 @@ int vsprintf(char *buf, const char *fmt, va_list args)
--fmt; --fmt;
continue; continue;
} }
if (flags & SIGN) { if (*fmt == 'p') {
num = (unsigned long)va_arg(args, void *);
} else if (flags & SIGN) {
switch (qualifier) { switch (qualifier) {
case 'L': case 'L':
num = va_arg(args, long long); num = va_arg(args, long long);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment