From 0b6b6c7f45b3fa3eab611df91cb181f29d45f8ed Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 6 Jul 2008 16:16:15 -0700 Subject: [PATCH] --- yaml --- r: 98749 b: refs/heads/master c: 78a8bf69b32980879975f7e31d30386c50bfe851 h: refs/heads/master i: 98747: 0187a5fba719d672dc41ab2092c78fbf9debab84 v: v3 --- [refs] | 2 +- trunk/lib/vsprintf.c | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/[refs] b/[refs] index 8f25fed53b5c..14994f9d70d8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 0f9bfa569d46f2346a53a940b2b9e49a38635732 +refs/heads/master: 78a8bf69b32980879975f7e31d30386c50bfe851 diff --git a/trunk/lib/vsprintf.c b/trunk/lib/vsprintf.c index 926c7e00e2dc..f569feb7662e 100644 --- a/trunk/lib/vsprintf.c +++ b/trunk/lib/vsprintf.c @@ -511,6 +511,16 @@ static char *string(char *buf, char *end, char *s, int field_width, int precisio return buf; } +static char *pointer(char *buf, char *end, void *ptr, int field_width, int precision, int flags) +{ + flags |= SMALL; + if (field_width == -1) { + field_width = 2*sizeof(void *); + flags |= ZEROPAD; + } + return number(buf, end, (unsigned long) ptr, 16, field_width, precision, flags); +} + /** * vsnprintf - Format a string and place it in a buffer * @buf: The buffer to place the result into @@ -653,17 +663,9 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) continue; case 'p': - flags |= SMALL; - if (field_width == -1) { - field_width = 2*sizeof(void *); - flags |= ZEROPAD; - } - str = number(str, end, - (unsigned long) va_arg(args, void *), - 16, field_width, precision, flags); + str = pointer(str, end, va_arg(args, void *), field_width, precision, flags); continue; - case 'n': /* FIXME: * What does C99 say about the overflow case here? */