diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-05 14:02:51 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-12-09 14:56:24 +1000 |
commit | 2abe83df686ed64c4f4df711ac3c1fd12131c2e4 (patch) | |
tree | 4441348021f601c268364b78f7371a291465c51f | |
parent | 4fc797f3756611a97767f407e1af0b6a7cf2f1d9 (diff) |
include: add BUG_WARN_MSG for custom error message on bug condition
__BUG_WARN_MSG is a simple helper to enable call with and without varargs. I
couldn't find a way to otherwise do this without getting gcc warnings.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
-rw-r--r-- | include/misc.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/include/misc.h b/include/misc.h index ef86fa539..d9811ca60 100644 --- a/include/misc.h +++ b/include/misc.h @@ -359,11 +359,18 @@ 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) \ +/* Don't use this directly, use BUG_WARN or BUG_WARN_MSG instead */ +#define __BUG_WARN_MSG(cond, with_msg, ...) \ do { if (cond) { \ ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \ __FILE__, __LINE__, __func__); \ + if (with_msg) ErrorF(__VA_ARGS__); \ xorg_backtrace(); \ } } while(0) +#define BUG_WARN_MSG(cond, msg, ...) \ + __BUG_WARN_MSG(cond, 1, msg, __VA_ARGS__) + +#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL) + #endif /* MISC_H */ |