[Mesa-dev] [PATCH] vbo: fix debug message format string in case of 32-bit machines

Brian Paul brianp at vmware.com
Tue Aug 2 14:13:31 UTC 2016


On 08/01/2016 04:35 PM, Jan Ziak wrote:
> Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail.com>
> ---
>   src/mesa/vbo/vbo_exec_array.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
> index 90f1321..fe74c73 100644
> --- a/src/mesa/vbo/vbo_exec_array.c
> +++ b/src/mesa/vbo/vbo_exec_array.c
> @@ -1680,7 +1680,7 @@ vbo_exec_MultiDrawArraysIndirectCount(GLenum mode,
>
>      if (MESA_VERBOSE & VERBOSE_DRAW)
>         _mesa_debug(ctx, "glMultiDrawArraysIndirectCountARB"
> -                  "(%s, %lx, %lx, %i, %i)\n",
> +                  "(%s, %zx, %zx, %i, %i)\n",
>                     _mesa_enum_to_string(mode), indirect,
>                     drawcount, maxdrawcount, stride);
>
> @@ -1708,7 +1708,7 @@ vbo_exec_MultiDrawElementsIndirectCount(GLenum mode, GLenum type,
>
>      if (MESA_VERBOSE & VERBOSE_DRAW)
>         _mesa_debug(ctx, "glMultiDrawElementsIndirectCountARB"
> -                  "(%s, %s, %lx, %lx, %i, %i)\n",
> +                  "(%s, %s, %zx, %zx, %i, %i)\n",
>                     _mesa_enum_to_string(mode),
>                     _mesa_enum_to_string(type), indirect,
>                     drawcount, maxdrawcount, stride);

Unfortunately, the MSVC compiler (er, the runtime) doesn't understand 
the 'z' modifier.

I just tried a test program with a printf("test %zx\n", k) where k's 
type is size_t.  The output was "test zx".

I also tried the mingw compiler and got:

   Compiling src/mesa/vbo/vbo_exec_array.c ...
src/mesa/vbo/vbo_exec_array.c: In function 
‘vbo_exec_MultiDrawArraysIndirectCount’:
src/mesa/vbo/vbo_exec_array.c:1662:19: warning: unknown conversion type 
character ‘z’ in format [-Wformat]
src/mesa/vbo/vbo_exec_array.c:1662:19: warning: unknown conversion type 
character ‘z’ in format [-Wformat]
src/mesa/vbo/vbo_exec_array.c:1662:19: warning: too many arguments for 
format [-Wformat-extra-args]

Even without your patch, we've had a few mingw warnings in the same place:

   Compiling src/mesa/vbo/vbo_exec_array.c ...
src/mesa/vbo/vbo_exec_array.c: In function 
‘vbo_exec_MultiDrawArraysIndirectCount’:
src/mesa/vbo/vbo_exec_array.c:1662:19: warning: format ‘%lx’ expects 
argument of type ‘long unsigned int’, but argument 4 has type ‘GLintptr’ 
[-Wformat]
src/mesa/vbo/vbo_exec_array.c:1662:19: warning: format ‘%lx’ expects 
argument of type ‘long unsigned int’, but argument 5 has type ‘GLintptr’ 
[-Wformat]


In bufferobj.c, it looks like we're just using %d or %s and casting the 
arguments to int.  But in other places, we're using %ld and casting to 
long.  That's not going to accurately report 64-bit values, but I guess 
that hasn't been a concern so far.

-Brian




More information about the mesa-dev mailing list