error: only evaluate argument once
In case the error macros are called directly on a function, make sure to evaluate
it precisely once.
@@ -13,14 +13,17 @@ int error_slow_fold(int r, const char *function, const char *file, int line);
/**
* error_origin() - XXX
*/
-#define error_origin(r) (_c_likely_(r == 0) ? 0 : error_slow_origin(r, __func__, __FILE__, __LINE__))
+#define error_origin(r) C_CC_MACRO1(ERROR_ORIGIN, (r))
+#define ERROR_ORIGIN(r) (_c_likely_(r == 0) ? 0 : error_slow_origin(r, __func__, __FILE__, __LINE__))
/**
* error_fold() - XXX
*/
-#define error_fold(r) (_c_likely_(r >= 0) ? error_origin(r) : error_slow_fold(r, __func__, __FILE__, __LINE__))
+#define error_fold(r) C_CC_MACRO1(ERROR_FOLD, (r))
+#define ERROR_FOLD(r) (_c_likely_(r >= 0) ? ERROR_ORIGIN(r) : error_slow_fold(r, __func__, __FILE__, __LINE__))
/**
* error_trace() - XXX
*/
-#define error_trace(r) (_c_likely_(r >= 0) ? r : error_slow_fold(r, __func__, __FILE__, __LINE__))
+#define error_trace(r) C_CC_MACRO1(ERROR_TRACE, (r))
+#define ERROR_TRACE(r) (_c_likely_(r >= 0) ? r : error_slow_fold(r, __func__, __FILE__, __LINE__))
