Re: Strange ipfw change (Sparc bugfix?)

Alan Modra (alan@spri.levels.unisa.edu.au)
Thu, 10 Sep 1998 16:49:38 +0930 (CST)


On Wed, 9 Sep 1998, pacman wrote:

> Geert Uytterhoeven writes the following:
> >
> >On Wed, 9 Sep 1998, Marc Duponcheel wrote:
> >>
> >> Sorry my ignorance but what does qualifier 'h' (implemented by
> >> vsprintf in kernel) actually mean in the printf family?
> >> the code goes like this:
> >>
> >> if (qualifier == 'h') {
> >> if (flags & SIGN)
> >> num = va_arg(args, short);
> >> else
> >> num = va_arg(args, unsigned short);
> >> }
>
> Attempting to get a short out of va_arg should set off major alarms. It's
> impossible to pass a short in a variadic argument list, because the argument
> promotion rules will make it into an int. Therefore va_arg(foo, short) is
> always incorrect, regardless of context, no matter what foo may be. (The same
> is true off va_arg'ing chars and floats. They will become ints and doubles.)
> gcc should have a warning about this...

gcc indeed knows that a short, char, float etc are promoted. Check
stdarg.h or varargs.h. You'll see that the size of the requested type is
rounded up as necessary. No problem.

-
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/faq.html