aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-04-10 15:25:21 +0200
committerJosh Triplett <josh@freedesktop.org>2008-04-21 11:06:22 -0700
commit7f91144d2de97bcbf26d980830646cac25e2b7df (patch)
tree29c12ddfb6c970ca601d8765cdf9fa4990de255d
parentc5b808c9964d62fc026d9398a4a62c3ce7bacac8 (diff)
downloadsparse-7f91144d2de97bcbf26d980830646cac25e2b7df.tar.gz
sparse-7f91144d2de97bcbf26d980830646cac25e2b7df.tar.xz
sparse-7f91144d2de97bcbf26d980830646cac25e2b7df.zip
sparse test suite: add test mixing __context__ and __attribute__((context(...)))
An earlier version of the next patch had a bug that this test catches. Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
-rw-r--r--validation/context-named.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/validation/context-named.c b/validation/context-named.c
index c65b202..d5573f4 100644
--- a/validation/context-named.c
+++ b/validation/context-named.c
@@ -465,6 +465,27 @@ static void warn_exact_fn2(void)
r2();
}
+#define __acquire(x) __context__(x,1)
+#define __release(x) __context__(x,-1)
+
+#define rl() \
+ do { __acquire(RCU); } while (0)
+
+#define ru() \
+ do { __release(RCU); } while (0)
+
+static void good_mixed_with_if(void)
+{
+ rl();
+
+ if (condition) {
+ a();
+ r();
+ }
+
+ ru();
+}
+
/*
* check-name: Check -Wcontext with lock names
*