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

Ben Pfaff (pfaffben@pilot.msu.edu)
18 Nov 1998 22:23:48 -0500


Linus Torvalds <torvalds@transmeta.com> writes:

On Wed, 18 Nov 1998, R Shapiro wrote:
> Linus Torvalds writes:
> > it (ie instead of using
> >
> > num = va_arg(args, short);
> >
> > it might be proper to use
> >
> > num = (short) va_args(args, int);

However, I also suspect that the first version really _should_ work, and
that it really is a problem in gcc or the varargs header files that makes
it not work.

Alternatively, I'd really like to know whether maybe the C standard really
says that you _have_ to use the second form. It's possible it does.

Reading section 7.8.1.2 of the ANSI C standard (/word/ corresponds to
italics):

#include <stdarg.h>
/type/ va_arg (va_list ap, /type/)

...if /type/ is not compatible with the type of the actual next
argument (as promoted according to the default argument
promotions), the behavior is undefined.

Section 6.1.2.6 defines compatible types:

Two types have /compatible types/ if their types are the same...

There are additional rules for compatibility but none apply in this
case AFAICS.

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