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:
parent
3b1d190831
commit
6d3f1e322e
@ -113,15 +113,15 @@
|
|||||||
#if defined(DEBUG_STRICT)
|
#if defined(DEBUG_STRICT)
|
||||||
#define BUG_ON(cond) _BUG_ON (cond, __FILE__, __LINE__, 3, "FATAL: bug ", "")
|
#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(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)
|
#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 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(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
|
#else
|
||||||
#define BUG_ON(cond)
|
#define BUG_ON(cond)
|
||||||
#define WARN_ON(cond)
|
#define WARN_ON(cond)
|
||||||
#define WARN_ON_ONCE(cond)
|
#define CHECK_IF(cond)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* When not optimizing, clang won't remove that code, so only compile it in when optimizing */
|
/* When not optimizing, clang won't remove that code, so only compile it in when optimizing */
|
||||||
|
@ -376,16 +376,16 @@ int debug_parse_cli_warn(char **args, char *payload, struct appctx *appctx, void
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse a "debug dev warn1" command. It always returns 1.
|
/* parse a "debug dev check" command. It always returns 1.
|
||||||
* Note: we make sure not to make the function static so that it appears in the trace.
|
* Note: we make sure not to make the function static so that it appears in the trace.
|
||||||
*/
|
*/
|
||||||
int debug_parse_cli_warn1(char **args, char *payload, struct appctx *appctx, void *private)
|
int debug_parse_cli_check(char **args, char *payload, struct appctx *appctx, void *private)
|
||||||
{
|
{
|
||||||
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
|
if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
_HA_ATOMIC_INC(&debug_commands_issued);
|
_HA_ATOMIC_INC(&debug_commands_issued);
|
||||||
WARN_ON_ONCE(one > zero);
|
CHECK_IF(one > zero);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1398,6 +1398,7 @@ REGISTER_PER_THREAD_INIT(init_debug_per_thread);
|
|||||||
/* register cli keywords */
|
/* register cli keywords */
|
||||||
static struct cli_kw_list cli_kws = {{ },{
|
static struct cli_kw_list cli_kws = {{ },{
|
||||||
{{ "debug", "dev", "bug", NULL }, "debug dev bug : call BUG_ON() and crash", debug_parse_cli_bug, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "bug", NULL }, "debug dev bug : call BUG_ON() and crash", debug_parse_cli_bug, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
|
{{ "debug", "dev", "check", NULL }, "debug dev check : call CHECK_IF() and possibly crash", debug_parse_cli_check, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
{{ "debug", "dev", "close", NULL }, "debug dev close <fd> : close this file descriptor", debug_parse_cli_close, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "close", NULL }, "debug dev close <fd> : close this file descriptor", debug_parse_cli_close, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
{{ "debug", "dev", "delay", NULL }, "debug dev delay [ms] : sleep this long", debug_parse_cli_delay, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "delay", NULL }, "debug dev delay [ms] : sleep this long", debug_parse_cli_delay, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
#if defined(DEBUG_DEV)
|
#if defined(DEBUG_DEV)
|
||||||
@ -1417,7 +1418,6 @@ static struct cli_kw_list cli_kws = {{ },{
|
|||||||
{{ "debug", "dev", "sym", NULL }, "debug dev sym <addr> : resolve symbol address", debug_parse_cli_sym, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "sym", NULL }, "debug dev sym <addr> : resolve symbol address", debug_parse_cli_sym, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
{{ "debug", "dev", "tkill", NULL }, "debug dev tkill [thr] [sig] : send signal to thread", debug_parse_cli_tkill, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "tkill", NULL }, "debug dev tkill [thr] [sig] : send signal to thread", debug_parse_cli_tkill, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
{{ "debug", "dev", "warn", NULL }, "debug dev warn : call WARN_ON() and possibly crash", debug_parse_cli_warn, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "warn", NULL }, "debug dev warn : call WARN_ON() and possibly crash", debug_parse_cli_warn, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
{{ "debug", "dev", "warn1", NULL }, "debug dev warn1 : call WARN_ON_ONCE() and possibly crash", debug_parse_cli_warn1, NULL, NULL, NULL, ACCESS_EXPERT },
|
|
||||||
{{ "debug", "dev", "write", NULL }, "debug dev write [size] : write that many bytes in return", debug_parse_cli_write, NULL, NULL, NULL, ACCESS_EXPERT },
|
{{ "debug", "dev", "write", NULL }, "debug dev write [size] : write that many bytes in return", debug_parse_cli_write, NULL, NULL, NULL, ACCESS_EXPERT },
|
||||||
#if defined(HA_HAVE_DUMP_LIBS)
|
#if defined(HA_HAVE_DUMP_LIBS)
|
||||||
{{ "show", "libs", NULL, NULL }, "show libs : show loaded object files and libraries", debug_parse_cli_show_libs, NULL, NULL },
|
{{ "show", "libs", NULL, NULL }, "show libs : show loaded object files and libraries", debug_parse_cli_show_libs, NULL, NULL },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user