* [merged] vsprintf-correctly-handle-width-when-flag-used-in-%p-format.patch removed from -mm tree
@ 2012-06-01 19:33 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2012-06-01 19:33 UTC (permalink / raw)
To: grant.likely, mm-commits
The patch titled
Subject: vsprintf: correctly handle width when '#' flag used in %#p format
has been removed from the -mm tree. Its filename was
vsprintf-correctly-handle-width-when-flag-used-in-%p-format.patch
This patch was dropped because it was merged into mainline or a subsystem tree
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
From: Grant Likely <grant.likely@secretlab.ca>
Subject: vsprintf: correctly handle width when '#' flag used in %#p format
The '%p' output of the kernel's vsprintf() uses spec.field_width to
determine how many digits to output based on 2 * sizeof(void*) so that all
digits of a pointer are shown. ie. a pointer will be output as
"001A2B3C" instead of "1A2B3C". However, if the '#' flag is used in the
format (%#p), then the code doesn't take into account the width of the
'0x' prefix and will end up outputing "0x1A2B3C" instead of "0x001A2B3C".
This patch reworks the "pointer()" format hook to include 2 characters for
the '0x' prefix if the '#' flag is included.
[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
lib/vsprintf.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff -puN lib/vsprintf.c~vsprintf-correctly-handle-width-when-flag-used-in-%p-format lib/vsprintf.c
--- a/lib/vsprintf.c~vsprintf-correctly-handle-width-when-flag-used-in-%p-format
+++ a/lib/vsprintf.c
@@ -870,13 +870,15 @@ static noinline_for_stack
char *pointer(const char *fmt, char *buf, char *end, void *ptr,
struct printf_spec spec)
{
+ int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
+
if (!ptr && *fmt != 'K') {
/*
* Print (null) with the same width as a pointer so it makes
* tabular output look nice.
*/
if (spec.field_width == -1)
- spec.field_width = 2 * sizeof(void *);
+ spec.field_width = default_width;
return string(buf, end, "(null)", spec);
}
@@ -931,7 +933,7 @@ char *pointer(const char *fmt, char *buf
*/
if (in_irq() || in_serving_softirq() || in_nmi()) {
if (spec.field_width == -1)
- spec.field_width = 2 * sizeof(void *);
+ spec.field_width = default_width;
return string(buf, end, "pK-error", spec);
}
if (!((kptr_restrict == 0) ||
@@ -948,7 +950,7 @@ char *pointer(const char *fmt, char *buf
}
spec.flags |= SMALL;
if (spec.field_width == -1) {
- spec.field_width = 2 * sizeof(void *);
+ spec.field_width = default_width;
spec.flags |= ZEROPAD;
}
spec.base = 16;
_
Patches currently in -mm which might be from grant.likely@secretlab.ca are
origin.patch
linux-next.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-06-01 19:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-01 19:33 [merged] vsprintf-correctly-handle-width-when-flag-used-in-%p-format.patch removed from -mm tree akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.