windcharger: add 'z' vfprintf length modifier
b/22209758
Change-Id: I4ec88d4b19533022a043becc94d3dd0b7f7aebd3
diff --git a/lib_generic/vsprintf.c b/lib_generic/vsprintf.c
index 2740f2e..e9f7113 100755
--- a/lib_generic/vsprintf.c
+++ b/lib_generic/vsprintf.c
@@ -202,7 +202,7 @@
int field_width; /* width of output field */
int precision; /* min. # of digits for integers; max
number of chars for from string */
- int qualifier; /* 'h', 'l', or 'q' for integer fields */
+ int qualifier; /* 'h', 'l', 'q' or 'z' for integer fields */
for (str=buf ; *fmt ; ++fmt) {
if (*fmt != '%') {
@@ -253,7 +253,7 @@
/* get the conversion qualifier */
qualifier = -1;
- if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q') {
+ if (*fmt == 'h' || *fmt == 'l' || *fmt == 'q' || *fmt == 'z') {
qualifier = *fmt;
++fmt;
}
@@ -337,6 +337,16 @@
--fmt;
continue;
}
+ if (qualifier == 'z') {
+ switch (sizeof(size_t)) {
+ case sizeof(unsigned long):
+ qualifier = 'l';
+ break;
+ case sizeof(unsigned long long):
+ qualifier = 'q';
+ break;
+ }
+ }
#ifdef CFG_64BIT_VSPRINTF
if (qualifier == 'q') /* "quad" for 64 bit variables */
num = va_arg(args, unsigned long long);