DEBUG: rename WARN_ON_ONCE() to CHECK_IF()

The only reason for warning once is to check if a condition really
happens. Let's use a term that better translates the intent, that's
important when reading the code.
This commit is contained in:
Willy Tarreau
2022-02-28 11:51:23 +01:00
parent 3b1d190831
commit 6d3f1e322e
2 changed files with 7 additions and 7 deletions

View File

@@ -113,15 +113,15 @@
#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 WARN_ON_ONCE(cond) _BUG_ON_ONCE(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)")
#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 WARN_ON_ONCE(cond) _BUG_ON_ONCE(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)")
#else
#define BUG_ON(cond)
#define WARN_ON(cond)
#define WARN_ON_ONCE(cond)
#define CHECK_IF(cond)
#endif
/* When not optimizing, clang won't remove that code, so only compile it in when optimizing */