diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-11-09 14:37:26 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-11-29 15:13:29 +1000 |
commit | 9c38422fc4cf853c3104fada2a3851c79df2a66f (patch) | |
tree | 11a66343b977150c743bc228c5147af025cbadc9 /include/misc.h | |
parent | 61ef4daf6450da573b9de72ba7b200566821b916 (diff) |
include: add BUG_WARN macro for internal bug cases.
There are plenty of cases that can only be triggered by a real bug in the
server and doing the ErrorF dance manually everywhere is a tad painful and
the error message is usually used only to find the spot in the file anyway.
Plus, reading BUG_WARN somewhere is a good indicator to the casual reader
that this isn't intended behaviour.
Note that this is intentionally different to the BUG_ON behaviour on the
kernel, we do not FatalError the server. It's just a warning + stacktrace.
If the bug is really fatal, call FatalError.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'include/misc.h')
-rw-r--r-- | include/misc.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/misc.h b/include/misc.h index 2e8dd1b89..ef86fa539 100644 --- a/include/misc.h +++ b/include/misc.h @@ -359,4 +359,11 @@ typedef struct _CharInfo *CharInfoPtr; /* also in fonts/include/font.h */ extern _X_EXPORT unsigned long globalSerialNumber; extern _X_EXPORT unsigned long serverGeneration; +#define BUG_WARN(cond) \ + do { if (cond) { \ + ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \ + __FILE__, __LINE__, __func__); \ + xorg_backtrace(); \ + } } while(0) + #endif /* MISC_H */ |