[quagga-dev 4367] Re: bgpd printf size_t warning

Andrew J. Schorr aschorr at telemetry-investments.com
Tue Sep 19 18:38:19 BST 2006

On Tue, Sep 19, 2006 at 04:43:42PM +0100, Paul Jakma wrote:
> On Tue, 19 Sep 2006, Andrew J. Schorr wrote:
> >Any reason not to apply this trivial patch?  It seems like it was 
> >more work to have added the "XXX: warning" message than to patch 
> >the problem.  Or am I missing something subtle?
> I think it might just shift the warning to another architecture :). 
> Last I tried I couldn't find the magic format to make it /not/ warn 
> on both i386 and amd64 at same time with gcc..

Hmmm, I don't see that.  With my patch, I do not see a warning
message on either i386 or x86_64.

> The cast will obviously work though, yes.
> The real solution though is C99 %z, but not everything supports it.

Yes, of course, that would be best, but not all supported platforms
have this yet.

> But no strong opinion on the matter myself, other than a general 
> aversion to casting away warnings. :)

I don't think it's actually casting away a warning.  It's fixing two 
bugs in the current code:

1. The argument type of 'len' is size_t, so it's unsigned, so it's
a bug to print it with "%ld" (a signed format).

2. It's a bug to assume that a size_t will be passed on the stack
with the same width as a long.  We need to specify u_long so that
it's passed with the proper width on the stack to match the printf format.

Until such time as %z is available, I claim that this is the
correct solution (use "%lu" in format and cast to (u_long)).  Is there
another possible solution?


More information about the Quagga-dev mailing list