Commit 11ecfb88 authored by Peter Hutterer's avatar Peter Hutterer
Browse files

include: add BUG_RETURN_* macros



Helper functions to avoid things like

if (foo) {
    BUG_WARN(foo);
    return 1;
}
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: default avatarChase Douglas <chase.douglas@canonical.com>
Reviewed-by: Alan Coopersmith's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent ff41753b
......@@ -381,4 +381,16 @@ extern _X_EXPORT unsigned long serverGeneration;
#define BUG_WARN(cond) __BUG_WARN_MSG(cond, 0, NULL)
#define BUG_RETURN(cond) \
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return; } } while(0)
#define BUG_RETURN_MSG(cond, ...) \
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return; } } while(0)
#define BUG_RETURN_VAL(cond, val) \
do { if (cond) { __BUG_WARN_MSG(cond, 0, NULL); return (val); } } while(0)
#define BUG_RETURN_VAL_MSG(cond, val, ...) \
do { if (cond) { __BUG_WARN_MSG(cond, 1, __VA_ARGS__); return (val); } } while(0)
#endif /* MISC_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment