From: Willy Tarreau Date: Mon, 28 Feb 2022 13:15:41 +0000 (+0100) Subject: DEBUG: improve BUG_ON output message accuracy X-Git-Tag: v2.6-dev3~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ef16578822c9c2d5eb2f1cc33bd78ab4270bd210;p=thirdparty%2Fhaproxy.git DEBUG: improve BUG_ON output message accuracy Now we'll explicitly mention if the test was a bug/warn/check, and "FATAL" is only displayed when the process crashes. The non-crashing BUG_ON() also suggests to report to developers. --- diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index 03dea5156f..cf4e728853 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -111,17 +111,17 @@ * crashes using ABORT_NOW() above. */ #if defined(DEBUG_STRICT) -#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 3, "FATAL: bug ", "") -#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)") -#define CHECK_IF(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)") +# define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 3, "FATAL: bug ", "") +# define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: warn ", " (please report to developers)") +# define CHECK_IF(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: check ", " (please report to developers)") #elif defined(DEBUG_STRICT_NOCRASH) -#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 2, "FATAL: bug ", " (not crashing but process is untrusted now)") -#define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)") -#define CHECK_IF(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: ", " (please report to developers)") +# define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 2, "WARNING: bug ", " (not crashing but process is untrusted now, please report to developers)") +# define WARN_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 0, "WARNING: warn ", " (please report to developers)") +# define CHECK_IF(cond) _BUG_ON_ONCE(cond, __FILE__, __LINE__, 0, "WARNING: check ", " (please report to developers)") #else -#define BUG_ON(cond) -#define WARN_ON(cond) -#define CHECK_IF(cond) +# define BUG_ON(cond) +# define WARN_ON(cond) +# define CHECK_IF(cond) #endif /* When not optimizing, clang won't remove that code, so only compile it in when optimizing */