From fb55c2b22791386c737173e679d99b84bcf36a76 Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Fri, 26 Jul 2024 11:51:26 +0200 Subject: [PATCH] vkd3d: Emit an ERR() when reaching unreachable code. This way the ERR() configuration is reused for unreachable code. --- include/private/vkd3d_common.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 6b6b6a14..d9321439 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -108,17 +108,11 @@ static inline uint64_t align(uint64_t addr, size_t alignment) # define VKD3D_UNREACHABLE (void)0 #endif /* __GNUC__ */ -VKD3D_NORETURN static inline void vkd3d_unreachable_(const char *filename, unsigned int line) -{ - fprintf(stderr, "%s:%u: Aborting, reached unreachable code.\n", filename, line); - abort(); -} - -#ifdef NDEBUG -#define vkd3d_unreachable() VKD3D_UNREACHABLE -#else -#define vkd3d_unreachable() vkd3d_unreachable_(__FILE__, __LINE__) -#endif +#define vkd3d_unreachable() \ + do { \ + ERR("%s:%u: Unreachable code reached.\n", __FILE__, __LINE__); \ + VKD3D_UNREACHABLE; \ + } while (0) #ifdef VKD3D_NO_TRACE_MESSAGES #define TRACE(args...) do { } while (0) @@ -188,6 +182,12 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size); #define VKD3D_DBG_PRINTF_ERR(...) VKD3D_DBG_PRINTF(__VA_ARGS__) #endif +/* Used by vkd3d_unreachable(). */ +#ifdef VKD3D_CROSSTEST +#undef ERR +#define ERR(...) do { fprintf(stderr, __VA_ARGS__); abort(); } while (0) +#endif + #ifndef TRACE #define TRACE VKD3D_DBG_LOG(TRACE) #endif