'h' only makes sense for scanf, not printf.
>
> num = va_arg(args, short);
>
> it might be proper to use
>
> num = (short) va_args(args, int);
>
> But I _really_ don't want to just silently drop a documented feature.
>
> Why is it broken on ppc/sparc? I assume it's because they have the wrong
> byte order, but why does this bite only the Linux kernel - it should have
> bitten other things too?
>
The problem is the way stdarg is typically implemented (the va_arg
thing casts something magically to a pointer whose type is taken from
the second argument.) I am 99.9% sure that using a promoted type in
va_arg is incorrect, and that the second form is the correct one.
The error occurs on bigendian machines because you're effectively
doing the moral equivalent of:
foo = *(short *)(&args[n--]);
instead of
foo = (short) *(int *)(&args[n--]);
... which is the same of littleendian boxen but not bigendian.
-hpa
-- PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD 1E DF FE 69 EE 35 BD 74 See http://www.zytor.com/~hpa/ for web page and full PGP public key I am Bahá'í -- ask me about it or see http://www.bahai.org/ "To love another person is to see the face of God." -- Les Misérables- 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/