summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-05-10 11:48:05 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-06-07 13:30:35 +1000
commit11ecfb8884b7c4def0863a57868a6b9fa1b63ae5 (patch)
treeede3f3dd945c9402273e74baa8461c0f1220884b /include
parentff41753b1bee414b16c0f1e8d183776e87c94065 (diff)
include: add BUG_RETURN_* macros
Helper functions to avoid things like if (foo) { BUG_WARN(foo); return 1; } 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')
-rw-r--r--include/misc.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/misc.h b/include/misc.h
index 41c13332a..fea74b86c 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -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 */