Messages in this thread Patch in this message | | | From | "Sean Hunter" <> | Date | Sat, 24 Jul 1999 00:31:15 +0100 | Subject | [PATCH] size_t now supported in printk |
| |
I've been asked to submit this patch, which adds "%z" support to vsprintf. This allows printk et al to print size_t's without a cast cleanly on all architectures.
I've altered it from my original version, so it uses the standard "z" qualifier instead of "Z", whicxh is a gnu extension.
The patch is against 2.2.10, but I don't think anything has touched this file for quite some time, so it'll probably go cleanly everywhere.
Sean
--- linux.vanilla/lib/vsprintf.c Wed Jul 21 12:05:34 1999 +++ linux/lib/vsprintf.c Fri Jul 23 17:25:48 1999 @@ -156,7 +156,9 @@ int precision; /* min. # of digits for integers; max number of chars for from string */ int qualifier; /* 'h', 'l', or 'L' for integer fields */ + /* 'z' support added 23/7/1999 S.H. */ + for (str=buf ; *fmt ; ++fmt) { if (*fmt != '%') { *str++ = *fmt; @@ -206,7 +208,7 @@ /* get the conversion qualifier */ qualifier = -1; - if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L') { + if (*fmt == 'h' || *fmt == 'l' || *fmt == 'L' || *fmt =='z') { qualifier = *fmt; ++fmt; } @@ -255,6 +257,9 @@ if (qualifier == 'l') { long * ip = va_arg(args, long *); *ip = (str - buf); + } else if (qualifier == 'z') { + size_t * ip = va_arg(args, size_t *); + *ip = (str - buf); } else { int * ip = va_arg(args, int *); *ip = (str - buf); @@ -292,6 +297,8 @@ } if (qualifier == 'l') num = va_arg(args, unsigned long); + else if (qualifier == 'z') + num = va_arg(args, size_t); else if (qualifier == 'h') { num = (unsigned short) va_arg(args, int); if (flags & SIGN)
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |