Re: [PATCH] Re: [ipchains] logging tcp/udp port numbers

Paul Rusty Russell (Paul.Russell@rustcorp.com.au)
Thu, 19 Nov 1998 13:18:56 +1130


In message <Pine.LNX.3.95.981118082435.3309A-100000@penguin.transmeta.com> you
write:
>
>
> On Wed, 18 Nov 1998, Paul Rusty Russell wrote:
> >
> > The %h printk modifier is used in 5 source files, and doesn't work on
> > ppc and sparc (vararg passing a short is broken on these platforms it
> > seems).
>
> If varargs is broken on them,

I can't find anything on the legality of pulling an unpromoted type
out of va_arg. However, it's obvious that pulling the promoted type
can *never* be wrong, so it's safer.

For reference, glibc's vfprintf has code like:

else /* `short int' will be promoted to `int'. */
signed_number = va_arg (ap, int);

and
number.word = (unsigned short int) va_arg (ap, unsigned int);

> But I _really_ don't want to just silently drop a documented feature.

Reread patch; I'm not dropping it. Ignoring the `h' qualifier is the
right thing to do except in the already-broken case of an actual int,
eg:

printk("%hu", 65536);

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

I've been bitten years ago; nowadays I always pull the promoted type
out of varargs. Seems I'm not alone.

Rusty.

--
 .sig lost in the mail.

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