[PATCH] size_t now supported in printk

Sean Hunter (sean@uncarved.co.uk)
Fri, 23 Jul 1999 16:52:51 +0100


By popular demand, this patch allows the use of the "%Z" qualifier to
denote a size_t argument to vsprintf (and thus printk). A number of
people have told me that this would be useful to reduce the need for
casts on non-intel architectures. I have seen this need myself in
trying to remove compile warnings on Alpha.

The patch is agains 2.2.10, but I don't think anything has touched
this file for quite some time, so it'll probably go cleanly
everywhere. Please feel free to apply, test, flame etc. If feedback
is positive I'll send it to Alan and Linus with a suitably grovelling
request for inclusion.

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)

----- End forwarded message -----

-
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/