From 2745f7a7d56a5cf73d41e274ad522045e9c6f920 Mon Sep 17 00:00:00 2001 From: "W. Felix Handte" Date: Thu, 30 Apr 2020 12:26:29 -0400 Subject: [PATCH] Make Error Macro Invocation Without Info String Fail to Compile Even without `-pedantic`, these macros will now fail to compile unless you provide an info string argument. This will prevent us from regressing. --- lib/common/zstd_internal.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/common/zstd_internal.h b/lib/common/zstd_internal.h index 950b789cf..05225e32e 100644 --- a/lib/common/zstd_internal.h +++ b/lib/common/zstd_internal.h @@ -62,8 +62,8 @@ extern "C" { */ #define RETURN_ERROR_IF(cond, err, ...) \ if (cond) { \ - RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \ - RAWLOG(3, ": " __VA_ARGS__); \ + RAWLOG(3, "%s:%d: ERROR!: check %s failed, returning %s: ", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \ + RAWLOG(3, __VA_ARGS__); \ RAWLOG(3, "\n"); \ return ERROR(err); \ } @@ -75,8 +75,8 @@ extern "C" { */ #define RETURN_ERROR(err, ...) \ do { \ - RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \ - RAWLOG(3, ": " __VA_ARGS__); \ + RAWLOG(3, "%s:%d: ERROR!: unconditional check failed, returning %s: ", __FILE__, __LINE__, ZSTD_QUOTE(ERROR(err))); \ + RAWLOG(3, __VA_ARGS__); \ RAWLOG(3, "\n"); \ return ERROR(err); \ } while(0); @@ -90,8 +90,8 @@ extern "C" { do { \ size_t const err_code = (err); \ if (ERR_isError(err_code)) { \ - RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s", __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \ - RAWLOG(3, ": " __VA_ARGS__); \ + RAWLOG(3, "%s:%d: ERROR!: forwarding error in %s: %s: ", __FILE__, __LINE__, ZSTD_QUOTE(err), ERR_getErrorName(err_code)); \ + RAWLOG(3, __VA_ARGS__); \ RAWLOG(3, "\n"); \ return err_code; \ } \