summaryrefslogtreecommitdiff
path: root/sys/dev/pci/drm
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-12-01 09:13:47 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-12-01 09:13:47 +0000
commit9426780a2bf42db1f624eb26b2cd8b9c4e9342d2 (patch)
treedeca7f85db13bc43a113c582358be0b4b10ec32e /sys/dev/pci/drm
parent6f2352b2f42759701155820d1f962482e19aad7a (diff)
Fix WARN() and WARN_ON(); the condition should only be evaluated once.
Properly implement WARN_ON_ONCE() as well. ok jsg@
Diffstat (limited to 'sys/dev/pci/drm')
-rw-r--r--sys/dev/pci/drm/drmP.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 081682538f2..f6fcceda2c0 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.154 2013/11/27 20:41:19 kettenis Exp $ */
+/* $OpenBSD: drmP.h,v 1.155 2013/12/01 09:13:46 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -163,22 +163,31 @@ do { \
#define BUG_ON(x) KASSERT(!(x))
#define WARN(condition, fmt...) ({ \
- if (condition) \
+ int __ret = !!(condition); \
+ if (__ret) \
printf(fmt); \
- (condition); \
+ unlikely(__ret); \
})
#define _WARN_STR(x) #x
#define WARN_ON(condition) ({ \
- if (condition) \
+ int __ret = !!(condition); \
+ if (__ret) \
printf("WARNING %s failed at %s:%d\n", \
_WARN_STR(condition), __FILE__, __LINE__); \
- (condition); \
+ unlikely(__ret); \
})
#define WARN_ON_ONCE(condition) ({ \
- (condition); \
+ static int __warned; \
+ int __ret = !!(condition); \
+ if (__ret && !__warned) { \
+ printf("WARNING %s failed at %s:%d\n", \
+ _WARN_STR(condition), __FILE__, __LINE__); \
+ __warned = 1; \
+ } \
+ unlikely(__ret); \
})
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-ELAST)