]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Make Error Macro Invocation Without Info String Fail to Compile
authorW. Felix Handte <w@felixhandte.com>
Thu, 30 Apr 2020 16:26:29 +0000 (12:26 -0400)
committerW. Felix Handte <w@felixhandte.com>
Mon, 4 May 2020 14:59:15 +0000 (10:59 -0400)
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

index 950b789cf4427c78ad3f97f60c687d66aeaf8078..05225e32e243f7e9073a5a04ae3fc60436ff70f8 100644 (file)
@@ -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; \
     } \