]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
Add RETURN_ERROR_IF Macro That Logs Debug Information When Check Fails
authorW. Felix Handte <w@felixhandte.com>
Thu, 6 Dec 2018 00:23:18 +0000 (16:23 -0800)
committerW. Felix Handte <w@felixhandte.com>
Mon, 28 Jan 2019 16:43:33 +0000 (11:43 -0500)
lib/common/zstd_internal.h

index edeb74b9c3a27fbe45cde4627222ed9ba393be02..73fc7705b94c09051a118cd7f98d67c427e03aa1 100644 (file)
@@ -56,6 +56,14 @@ extern "C" {
 #define CHECK_F(f) { size_t const errcod = f; if (ERR_isError(errcod)) return errcod; }  /* check and Forward error code */
 #define CHECK_E(f, e) { size_t const errcod = f; if (ERR_isError(errcod)) return ERROR(e); }  /* check and send Error code */
 
+#define RETURN_ERROR_IF(cond, err, ...) \
+  if (cond) { \
+    RAWLOG(3, "%s:%d: check %s failed, returning %s", __FILE__, __LINE__, ZSTD_QUOTE(cond), ZSTD_QUOTE(ERROR(err))); \
+    RAWLOG(3, ": " __VA_ARGS__); \
+    RAWLOG(3, "\n"); \
+    return ERROR(err); \
+  }
+
 
 /*-*************************************
 *  Common constants