[Mesa-dev] [PATCH 14/23] main: Refactor MapBuffer[Range].

Ilia Mirkin imirkin at alum.mit.edu
Sat Mar 28 09:09:24 PDT 2015


On Wed, Feb 11, 2015 at 9:05 PM, Laura Ekstrand <laura at jlekstrand.net> wrote:
>     if (offset + length > bufObj->Size) {
>        _mesa_error(ctx, GL_INVALID_VALUE,
> -                  "glMapBufferRange(offset + length > size)");
> +                  "%s(offset %d + length %d > buffer_size %d)", func,
> +                  (int) offset, (int) length, (int) bufObj->Size);
>        return NULL;
>     }

I now get the following warning (on 32-bit ARM, but presumably 32-bit
x86 or even x32 would be the same thing):

main/bufferobj.c: In function '_mesa_map_buffer_range':
main/bufferobj.c:2340:19: warning: format '%ld' expects argument of
type 'long int', but argument 5 has type 'GLintptr' [-Wformat=]
                   offset, length, bufObj->Size);
                   ^
main/bufferobj.c:2340:19: warning: format '%ld' expects argument of
type 'long int', but argument 6 has type 'GLsizeiptr' [-Wformat=]
main/bufferobj.c:2340:19: warning: format '%ld' expects argument of
type 'long int', but argument 7 has type 'GLsizeiptrARB' [-Wformat=]

There's a %zu which might be old enough by now to work everywhere
(iirc it didn't exist in like GCC 2.95, but those days are thankfully
behind us). If not, there are the PRIuS style macros...

Looks like http://src.chromium.org/svn/trunk/src/base/format_macros.h does

#ifdef OS_POSIX

#if !defined(PRIuS)
#define PRIuS "zu"
#endif

#else /* OS_WIN */

#if !defined(PRIuS)
#define PRIuS "Iu"
#endif

#endif

Perhaps we could adapt something like that. Or perhaps there's an
existing way of dealing with such annoyances, like casting.

  -ilia


More information about the mesa-dev mailing list