[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/7] common/vsprintf: Refactor pointer() out of vsnprintf()



No fuctional change

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Keir Fraser <keir@xxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
 xen/common/vsprintf.c |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index 1bcbd79..5fdd391 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -261,6 +261,21 @@ static char *string(char *str, char *end, const char *s,
     return str;
 }
 
+static char *pointer(char *str, char *end,
+                     unsigned long val, int field_width, int precision,
+                     int flags)
+{
+    if ( field_width == -1 )
+    {
+        field_width = 2 * sizeof(void *);
+        flags |= ZEROPAD;
+    }
+
+    str = number(str, end, val, 16, field_width, precision, flags);
+
+    return str;
+}
+
 /**
  * vsnprintf - Format a string and place it in a buffer
  * @buf: The buffer to place the result into
@@ -399,13 +414,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, (unsigned long) va_arg(args, void *),
+                          field_width, precision, flags);
             continue;
 
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.