On Tue, 2 Jan 2001, Guy Harris wrote:

> On Mon, Jan 01, 2001 at 01:27:16AM +0200, Pekka Savola wrote:
> > On Red Hat Linux 7, compile fails.  Apparently this is caused by gcc
> > "2.96" which is stricter about the correctness of the code.  Other
> > snprintf implementations, e.g. one in OpenSSH, compile fine.
> >
> > Anyone more intimate with missing/snprintf.c?
>
> I've just looked at it now, but I suspect that "PARSE_INT_FORMAT()"
> should simply do
>
>       #define PARSE_INT_FORMAT(res, arg, unsig) \
>       if (long_flag) \
>            res = (unsig long)va_arg(arg, unsig long); \
>       else if (short_flag) \
>            res = (unsig short)va_arg(arg, unsig int); \
>       else \
>            res = (unsig int)va_arg(arg, unsig int)
>
> as the claim that
>
>       `short int' is promoted to `int' when passed through `...'
>
> is correct and the statement that
>
>       ...you should pass `int' not `short int' to `va_arg'
>
> is thus arguably correct.

Yes, this fix looks sane and appears to work.  I didn't do extended
testing with it though.

Nevertheless I'd suggest not using a custom snprintf unless it's strictly
necessary.

-- 
Pekka Savola                  "Tell me of difficulties surmounted,
Netcore Oy                    not those you stumble over and fall"
Systems. Networks. Security.   -- Robert Jordan: A Crown of Swords

-
This is the TCPDUMP workers list. It is archived at
http://www.tcpdump.org/lists/workers/index.html
To unsubscribe use mailto:[EMAIL PROTECTED]?body=unsubscribe

Reply via email to