Skip to content

anv: Avoid a couple of warnings related to vk_error macros

Caio Oliveira requested to merge cmarcelo/mesa:r/anv-fix-unused-warning into master

When DEBUG is not defined, no error reporting is done, the error is just returned back. The current definition a couple of warnings in anv_formats.c. First when the return value is intentionally ignored

  ../src/intel/vulkan/anv_formats.c:989:48: warning: statement with no effect [-Wunused-value]
    989 |          vk_errorfi(instance, physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
        |                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ../src/intel/vulkan/anv_private.h:486:55: note: in definition of macro ‘vk_errorfi’
    486 | #define vk_errorfi(instance, obj, error, format, ...) error
        |                                                       ^~~~~

and also when an argument is used only

  ../src/intel/vulkan/anv_formats.c:908:25: warning: unused variable ‘instance’ [-Wunused-variable]
    908 |    struct anv_instance *instance = physical_device->instance;
        |                         ^~~~~~~~
  ../src/intel/vulkan/anv_formats.c: In function ‘anv_GetPhysicalDeviceImageFormatProperties2’:
  ../src/intel/vulkan/anv_formats.c:1231:25: warning: unused variable ‘instance’ [-Wunused-variable]
   1231 |    struct anv_instance *instance = physical_device->instance;
        |                         ^~~~~~~~

to avoid both issues, use a static inline function that just returns it's argument but can consume other input. Ignoring the return value of a function is OK, and the extra input can be tagged as UNUSED getting rid of both warnings.

Edited by Caio Oliveira

Merge request reports