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>
This commit is contained in:
parent
4fc797f375
commit
2abe83df68
|
@ -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 globalSerialNumber;
|
||||||
extern _X_EXPORT unsigned long serverGeneration;
|
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) { \
|
do { if (cond) { \
|
||||||
ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \
|
ErrorF("BUG: triggered 'if (" #cond ")'\nBUG: %s:%d in %s()\n", \
|
||||||
__FILE__, __LINE__, __func__); \
|
__FILE__, __LINE__, __func__); \
|
||||||
|
if (with_msg) ErrorF(__VA_ARGS__); \
|
||||||
xorg_backtrace(); \
|
xorg_backtrace(); \
|
||||||
} } while(0)
|
} } 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 */
|
#endif /* MISC_H */
|
||||||
|
|
Loading…
Reference in New Issue