From: Andrew Cooper Date: Tue, 12 Nov 2013 10:06:45 +0000 (+0100) Subject: common/vsprintf: Refactor pointer() out of vsnprintf() X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~6001 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d41b853cc7e86fe6007b337d0b26accce0dcbefc;p=xen.git common/vsprintf: Refactor pointer() out of vsnprintf() No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Acked-by: Keir Fraser --- diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c index 4211ebee0d..db926dfe77 100644 --- a/xen/common/vsprintf.c +++ b/xen/common/vsprintf.c @@ -261,6 +261,20 @@ static char *string(char *str, char *end, const char *s, return str; } +static char *pointer(char *str, char *end, + const void *arg, int field_width, int precision, + int flags) +{ + if ( field_width == -1 ) + { + field_width = 2 * sizeof(void *); + flags |= ZEROPAD; + } + + return number(str, end, (unsigned long)arg, + 16, field_width, precision, flags); +} + /** * vsnprintf - Format a string and place it in a buffer * @buf: The buffer to place the result into @@ -399,13 +413,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) continue; case 'p': - 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, const void *), + field_width, precision, flags); continue;