[Mesa-dev] [PATCH] gallium/util: Silence GCC unused-but-set-variable warning.

Vinson Lee vlee at freedesktop.org
Wed Jul 29 20:43:33 PDT 2015


On Wed, Jul 29, 2015 at 8:33 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Wed, Jul 29, 2015 at 8:12 PM, Vinson Lee <vlee at freedesktop.org> wrote:
>> u_surface.c: In function 'util_resource_copy_region':
>> u_surface.c:257:21: warning: variable 'src_format' set but not used [-Wunused-but-set-variable]
>>     enum pipe_format src_format, dst_format;
>>                      ^
>>
>> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
>> ---
>>  src/gallium/auxiliary/util/u_surface.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
>> index 654b5bb..e362471 100644
>> --- a/src/gallium/auxiliary/util/u_surface.c
>> +++ b/src/gallium/auxiliary/util/u_surface.c
>> @@ -270,6 +270,7 @@ util_resource_copy_region(struct pipe_context *pipe,
>>     assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
>>     assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
>>     assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format));
>> +   (void) src_format;
>
> We've recently begun using gcc's __attribute__((unused)) -- There's a
> macro named UNUSED. I might suggest using it. I've seen some case
> where the (void) trick wasn't sufficient.

The variable is definitely used though in debug builds. Would unused
still be the appropriate annotation in these cases?


More information about the mesa-dev mailing list