Module: Mesa Branch: master Commit: 0a7abee60b699a6065edbe778cf990dd8d4910bb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a7abee60b699a6065edbe778cf990dd8d4910bb
Author: Caio Marcelo de Oliveira Filho <[email protected]> Date: Tue Dec 1 08:45:35 2020 -0900 anv: Avoid a couple of warnings related to vk_error macros 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. Reviewed-by: Jason Ekstrand <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7860> --- src/intel/vulkan/anv_private.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index fb23ec00e62..0b78f7a298f 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -482,9 +482,15 @@ VkResult __vk_errorf(struct anv_instance *instance, const void *object, vk_errorfi(anv_device_instance_or_null(device),\ obj, error, format, ## __VA_ARGS__) #else -#define vk_error(error) error -#define vk_errorfi(instance, obj, error, format, ...) error -#define vk_errorf(device, obj, error, format, ...) error + +static inline VkResult __dummy_vk_error(VkResult error, UNUSED const void *ignored) +{ + return error; +} + +#define vk_error(error) __dummy_vk_error(error, NULL) +#define vk_errorfi(instance, obj, error, format, ...) __dummy_vk_error(error, instance) +#define vk_errorf(device, obj, error, format, ...) __dummy_vk_error(error, device) #endif /** _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
