[PATCH] Suppress a warning about mismatched parameter in format string (expected long int, provided unsigned int).

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Wed Apr 25 05:15:33 PDT 2007


On 4/25/07, Zephaniah E. Hull <warp at aehallh.com> wrote:
> On Wed, Apr 25, 2007 at 03:06:27AM +0200, Giuseppe Bilotta wrote:
> > -            xf86Msg(X_ERROR, "Read error: %s (%d, %d != %ld)\n",
> > +            xf86Msg(X_ERROR, "Read error: %s (%d, %d != %u)\n",
> >                   strerror(errno), errno, len, sizeof (ev));
>
> See, this is one of those funky cases where fixing the warning is the
> wrong answer.
>
> See, on x86 sizeof returns an int, on amd64 sizeof returns a long, which
> makes it slightly harder to avoid a warning on all systems without using
> a cast.

Gotcha. Well, sizeof() is unsigned (isn't it?) so the problem is %lu
or %u (%ld I think was wrong anyway?). gcc has a 'z' format string
extension that handles this (%zu turns out as the correct architecture
dependent size_t) ... can we rely on it?

-- 
Giuseppe "Oblomov" Bilotta



More information about the xorg mailing list