From cc4b9c2128cd6b533d74a2fad01c016370218ff1 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Fri, 7 Aug 2020 16:05:46 +0200 Subject: [PATCH] radv: rework the error function helpers a bit Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/amd/vulkan/radv_private.h | 8 +++++++- src/amd/vulkan/radv_util.c | 28 +++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h index 603b0c94a22..0634350701e 100644 --- a/src/amd/vulkan/radv_private.h +++ b/src/amd/vulkan/radv_private.h @@ -194,7 +194,13 @@ radv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask) struct radv_image_view; struct radv_instance; -VkResult __vk_errorf(struct radv_instance *instance, VkResult error, const char *file, int line, const char *format, ...); +VkResult __vk_errorv(struct radv_instance *instance, VkResult error, + const char *file, int line, const char *format, + va_list args); + +VkResult __vk_errorf(struct radv_instance *instance, VkResult error, + const char *file, int line, const char *format, ...) + radv_printflike(5, 6); #define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL); #define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__); diff --git a/src/amd/vulkan/radv_util.c b/src/amd/vulkan/radv_util.c index 72bedc687d4..01224157e5e 100644 --- a/src/amd/vulkan/radv_util.c +++ b/src/amd/vulkan/radv_util.c @@ -88,11 +88,11 @@ void radv_printflike(3, 4) } VkResult -__vk_errorf(struct radv_instance *instance, VkResult error, const char *file, - int line, const char *format, ...) +__vk_errorv(struct radv_instance *instance, VkResult error, const char *file, + int line, const char *format, va_list ap) { - va_list ap; char buffer[256]; + char report[512]; const char *error_str = vk_Result_to_str(error); @@ -102,15 +102,29 @@ __vk_errorf(struct radv_instance *instance, VkResult error, const char *file, #endif if (format) { - va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); - va_end(ap); - fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str); + snprintf(report, sizeof(report), "%s:%d: %s (%s)", file, line, + buffer, error_str); } else { - fprintf(stderr, "%s:%d: %s\n", file, line, error_str); + snprintf(report, sizeof(report), "%s:%d: %s", file, line, + error_str); } + fprintf(stderr, "%s\n", report); + return error; } +VkResult +__vk_errorf(struct radv_instance *instance, VkResult error, const char *file, + int line, const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + __vk_errorv(instance, error, file, line, format, ap); + va_end(ap); + + return error; +} -- 2.30.2