diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-12-23 10:59:22 +0100 |
---|---|---|
committer | Chris Li <chrisl@slimtower.chrisli.org> | 2008-12-24 02:34:41 -0800 |
commit | 2479d0f7819bdc4328f28c317248f1a6f78e3e9f (patch) | |
tree | 7ae003d227abc6db5215c9762e25a11fae6ecf9f /validation | |
parent | Let void have sizeof 1 (diff) | |
download | sparse-2479d0f7819bdc4328f28c317248f1a6f78e3e9f.tar.gz sparse-2479d0f7819bdc4328f28c317248f1a6f78e3e9f.tar.bz2 sparse-2479d0f7819bdc4328f28c317248f1a6f78e3e9f.zip |
Revert the context tracking code
> Do you want to resend your change which revert the context changes?
> Make it base on Josh's git's tree and I will merge your changes in my
> branch.
Below. Or I can give it to you in git if you prefer. I still think we
should redo this in some form so that annotations with different
contexts can work properly, but I don't have time to take care of it
right now.
johannes
>From ca95b62edf1600a2b55ed9ca0515d049807a84fc Mon Sep 17 00:00:00 2001
From: Johannes Berg <johannes@sipsolutions.net>
Date: Tue, 23 Dec 2008 10:53:19 +0100
Subject: [PATCH] Revert context tracking code
Diffstat (limited to 'validation')
-rw-r--r-- | validation/context-dynamic.c | 171 | ||||
-rw-r--r-- | validation/context-named.c | 553 | ||||
-rw-r--r-- | validation/context-statement.c | 69 | ||||
-rw-r--r-- | validation/context.c | 114 |
4 files changed, 14 insertions, 893 deletions
diff --git a/validation/context-dynamic.c b/validation/context-dynamic.c deleted file mode 100644 index 5e172f0..0000000 --- a/validation/context-dynamic.c +++ /dev/null @@ -1,171 +0,0 @@ -static void a(void) __attribute__ ((context(A, 0, 1))) -{ - __context__(A, 1); -} - -static void r(void) __attribute__ ((context(A, 1, 0))) -{ - __context__(A, -1); -} - -extern int condition, condition2; - -static int tl(void) __attribute__ ((conditional_context(A, 0, 1, 0))) -{ - if (condition) { - a(); - return 1; - } - return 0; -} - -static int tl2(void) __attribute__ ((conditional_context(A, 0, 0, 1))) -{ - if (condition) { - a(); - return 1; - } - return 0; -} - -static int dummy(void) -{ - return condition + condition2; -} - -static int good_trylock1(void) -{ - if (tl()) { - r(); - } -} - -static int good_trylock2(void) -{ - if (tl()) { - r(); - } - - if (tl()) { - r(); - } -} -static int good_trylock3(void) -{ - a(); - if (tl()) { - r(); - } - r(); - if (tl()) { - r(); - } -} - -static int good_trylock4(void) -{ - a(); - if (tl()) { - r(); - } - if (tl()) { - r(); - } - r(); -} - -static void bad_trylock1(void) -{ - a(); - if (dummy()) { - r(); - } - r(); -} - -static int good_trylock5(void) -{ - if (!tl2()) { - r(); - } -} - -static int good_trylock6(void) -{ - if (!tl2()) { - r(); - } - - if (!tl2()) { - r(); - } -} -static int good_trylock7(void) -{ - a(); - if (!tl2()) { - r(); - } - r(); - if (!tl2()) { - r(); - } -} - -static int good_trylock8(void) -{ - a(); - if (!tl2()) { - r(); - } - if (!tl2()) { - r(); - } - r(); -} - -static void bad_trylock2(void) -{ - a(); - if (!dummy()) { - r(); - } - r(); -} - -static int good_switch(void) -{ - switch (condition) { - case 1: - a(); - break; - case 2: - a(); - break; - case 3: - a(); - break; - default: - a(); - } - r(); -} - -static void bad_lock1(void) -{ - r(); - a(); -} - -/* - * check-name: Check -Wcontext with lock trylocks - * - * check-error-start -context-dynamic.c:83:6: warning: context problem in 'bad_trylock1': 'r' expected different context -context-dynamic.c:83:6: context 'A': wanted >= 1, got 0 -context-dynamic.c:133:6: warning: context problem in 'bad_trylock2': 'r' expected different context -context-dynamic.c:133:6: context 'A': wanted >= 1, got 0 -context-dynamic.c:156:6: warning: context problem in 'bad_lock1': 'r' expected different context -context-dynamic.c:156:6: context 'A': wanted >= 1, got 0 - * check-error-end - */ diff --git a/validation/context-named.c b/validation/context-named.c deleted file mode 100644 index 58310e9..0000000 --- a/validation/context-named.c +++ /dev/null @@ -1,553 +0,0 @@ -static void a(void) __attribute__((context(TEST,0,1))) -{ - __context__(TEST,1); -} - -static void r(void) __attribute__((context(TEST,1,0))) -{ - __context__(TEST,-1,1); -} - -static void a2(void) __attribute__((context(TEST2,0,1))) -{ - __context__(TEST2,1); -} - -static void r2(void) __attribute__((context(TEST2,1,0))) -{ - __context__(TEST2,-1,1); -} - -#define check_test2() __context__(TEST2,0,1) - -static void good_paired1(void) -{ - a(); - a2(); - r(); - r2(); -} - -static void good_paired2(void) -{ - a(); - r(); - a(); - r(); - a2(); - r2(); -} - -static void good_paired3(void) -{ - a(); - a(); - r(); - r(); - a2(); - a2(); - r2(); - r2(); -} - -static void good_lock1(void) __attribute__((context(TEST,0,1))) -{ - a(); -} - -static void good_lock2(void) __attribute__((context(TEST,0,1))) -{ - a(); - r(); - a(); -} - -static void good_lock3(void) __attribute__((context(TEST,0,1))) -{ - a(); - a(); - r(); -} - -static void good_unlock1(void) __attribute__((context(TEST,1,0))) -{ - r(); -} - -static void good_unlock2(void) __attribute__((context(TEST,1,0))) -{ - a(); - r(); - r(); -} - -static void warn_lock1(void) -{ - a(); -} - -static void warn_lock2(void) -{ - a(); - r(); - a(); -} - -static void warn_lock3(void) -{ - a(); - a(); - r(); -} - -static void warn_unlock1(void) -{ - r(); -} - -static void warn_unlock2(void) -{ - a(); - r(); - r(); -} - -extern int condition, condition2; - -static int good_if1(void) -{ - a(); - if(condition) { - r(); - return -1; - } - r(); - return 0; -} - -static void good_if2(void) -{ - if(condition) { - a(); - r(); - } -} - -static void good_if3(void) -{ - a(); - if(condition) { - a(); - r(); - } - r(); -} - -static int warn_if1(void) -{ - a(); - if(condition) - return -1; - r(); - return 0; -} - -static int warn_if2(void) -{ - a(); - if(condition) { - r(); - return -1; - } - return 0; -} - -static void good_while1(void) -{ - a(); - while(condition) - ; - r(); -} - -static void good_while2(void) -{ - while(condition) { - a(); - r(); - } -} - -static void good_while3(void) -{ - while(condition) { - a(); - r(); - if(condition2) - break; - a(); - r(); - } -} - -static void good_while4(void) -{ - a(); - while(1) { - if(condition2) { - r(); - break; - } - } -} - -static void good_while5(void) -{ - a(); - while(1) { - r(); - if(condition2) - break; - a(); - } -} - -static void warn_while1(void) -{ - while(condition) { - a(); - } -} - -static void warn_while2(void) -{ - while(condition) { - r(); - } -} - -static void warn_while3(void) -{ - while(condition) { - a(); - if(condition2) - break; - r(); - } -} - -static void good_goto1(void) -{ - a(); - goto label; -label: - r(); -} - -static void good_goto2(void) -{ - a(); - goto label; - a(); - r(); -label: - r(); -} - -static void good_goto3(void) -{ - a(); - if(condition) - goto label; - a(); - r(); -label: - r(); -} - -static void good_goto4(void) -{ - if(condition) - goto label; - a(); - r(); -label: - ; -} - -static void good_goto5(void) -{ - a(); - if(condition) - goto label; - r(); - return; -label: - r(); -} - -static void warn_goto1(void) -{ - a(); - goto label; - r(); -label: - ; -} - -static void warn_goto2(void) -{ - a(); - goto label; - r(); -label: - a(); - r(); -} - -static void warn_goto3(void) -{ - a(); - if(condition) - goto label; - r(); -label: - r(); -} - -static void warn_multiple1(void) -{ - a(); - a2(); -} - -static void warn_multiple2(void) -{ - a2(); - a(); -} - -static void warn_mixed1(void) -{ - a2(); - r(); -} - -static void warn_mixed2(void) -{ - a2(); - if (condition) { - a(); - r2(); - } - r(); -} - -static void warn_mixed3(void) -{ - a2(); - if (condition) { - r2(); - return; - } - r(); -} - -static void warn_mixed4(void) -{ - a2(); - if (condition) { - a(); - r(); - return; - } - r(); -} - -static void good_mixed1(void) -{ - if (condition) { - a(); - r(); - } else { - a2(); - r2(); - } -} - -static void good_mixed2(void) -{ - if (condition) { - a(); - r(); - } - a2(); - r2(); -} - -static int need_lock(void) __attribute__((context(TEST,1,1))) -{ -} - -static void need_lock_exact(void) __attribute__((exact_context(TEST,1,1))) -{ -} - -static void need_lock2(void) __attribute__((context(TEST,1,1))) -{ - need_lock(); -} - -static void good_fn(void) -{ - a(); - need_lock(); - r(); -} - -static void good_fn2(void) -{ - a(); - a(); - need_lock(); - r(); - r(); -} - -static void good_fn2(void) -{ - a(); - if (condition) - need_lock(); - r(); -} - -static void good_fn3(void) __attribute__((context(TEST,1,1))) -{ - if (condition) - need_lock2(); -} - -static void warn_fn(void) -{ - a2(); - need_lock(); - r2(); -} - -static void warn_fn2(void) -{ - a2(); - need_lock2(); - r2(); -} - -static void good_exact_fn(void) -{ - a(); - need_lock_exact(); - r(); -} - -static void warn_exact_fn1(void) -{ - a(); - a(); - need_lock_exact(); - r(); - r(); -} - -static void warn_exact_fn2(void) -{ - a2(); - need_lock_exact(); - r2(); -} - -static inline void need_lock3(void) __attribute__((context(TEST,1,1))) -{ -} - -static void warn_fn3(void) -{ - a2(); - need_lock3(); - 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 - * - * check-error-start -context-named.c:86:3: warning: context imbalance in 'warn_lock1': wrong count at exit -context-named.c:86:3: context 'TEST': wanted 0, got 1 -context-named.c:93:3: warning: context imbalance in 'warn_lock2': wrong count at exit -context-named.c:93:3: context 'TEST': wanted 0, got 1 -context-named.c:100:3: warning: context imbalance in 'warn_lock3': wrong count at exit -context-named.c:100:3: context 'TEST': wanted 0, got 1 -context-named.c:105:3: warning: context problem in 'warn_unlock1': 'r' expected different context -context-named.c:105:3: context 'TEST': wanted >= 1, got 0 -context-named.c:112:3: warning: context problem in 'warn_unlock2': 'r' expected different context -context-named.c:112:3: context 'TEST': wanted >= 1, got 0 -context-named.c:152:9: warning: context imbalance in 'warn_if1': wrong count at exit -context-named.c:152:9: context 'TEST': wanted 0, got 1 -context-named.c:162:9: warning: context imbalance in 'warn_if2': wrong count at exit -context-named.c:162:9: context 'TEST': wanted 0, got 1 -context-named.c:218:4: warning: context imbalance in 'warn_while1': wrong count at exit -context-named.c:218:4: context 'TEST': wanted 0, got 1 -context-named.c:225:4: warning: context problem in 'warn_while2': 'r' expected different context -context-named.c:225:4: context 'TEST': wanted >= 1, got 0 -context-named.c:235:4: warning: context imbalance in 'warn_while3': wrong count at exit -context-named.c:235:4: context 'TEST': wanted 0, got 1 -context-named.c:295:5: warning: context imbalance in 'warn_goto1': wrong count at exit -context-named.c:295:5: context 'TEST': wanted 0, got 1 -context-named.c:305:6: warning: context imbalance in 'warn_goto2': wrong count at exit -context-named.c:305:6: context 'TEST': wanted 0, got 1 -context-named.c:315:6: warning: context problem in 'warn_goto3': 'r' expected different context -context-named.c:315:6: context 'TEST': wanted >= 1, got 0 -context-named.c:321:7: warning: context imbalance in 'warn_multiple1': wrong count at exit -context-named.c:321:7: context 'TEST': wanted 0, got 1 -context-named.c:327:6: warning: context imbalance in 'warn_multiple2': wrong count at exit -context-named.c:327:6: context 'TEST2': wanted 0, got 1 -context-named.c:333:6: warning: context problem in 'warn_mixed1': 'r' expected different context -context-named.c:333:6: context 'TEST': wanted >= 1, got 0 -context-named.c:343:6: warning: context problem in 'warn_mixed2': 'r' expected different context -context-named.c:343:6: context 'TEST': wanted >= 1, got 0 -context-named.c:353:6: warning: context problem in 'warn_mixed3': 'r' expected different context -context-named.c:353:6: context 'TEST': wanted >= 1, got 0 -context-named.c:364:6: warning: context imbalance in 'warn_mixed4': wrong count at exit -context-named.c:364:6: context 'TEST2': wanted 0, got 1 -context-named.c:434:14: warning: context problem in 'warn_fn': 'need_lock' expected different context -context-named.c:434:14: context 'TEST': wanted >= 1, got 0 -context-named.c:441:15: warning: context problem in 'warn_fn2': 'need_lock2' expected different context -context-named.c:441:15: context 'TEST': wanted >= 1, got 0 -context-named.c:456:20: warning: context problem in 'warn_exact_fn1': 'need_lock_exact' expected different context -context-named.c:456:20: context 'TEST': wanted 1, got 2 -context-named.c:464:20: warning: context problem in 'warn_exact_fn2': 'need_lock_exact' expected different context -context-named.c:464:20: context 'TEST': wanted 1, got 0 -context-named.c:475:15: warning: context problem in 'warn_fn3': 'need_lock3' expected different context -context-named.c:475:15: context 'TEST': wanted >= 1, got 0 - * check-error-end - */ diff --git a/validation/context-statement.c b/validation/context-statement.c deleted file mode 100644 index fd79a6a..0000000 --- a/validation/context-statement.c +++ /dev/null @@ -1,69 +0,0 @@ -#define a() __context__(LOCK, 1) -#define r() __context__(LOCK, -1) -#define m() __context__(LOCK, 0, 1) -#define m2() __context__(LOCK, 0, 2) - -static void good_ar(void) -{ - a(); - r(); -} - -static void bad_arr(void) -{ - a(); - r(); - r(); -} - -static void good_macro1(void) -{ - a(); - m(); - r(); -} - -static void good_macro2(void) -{ - a(); - a(); - m(); - m2(); - r(); - r(); -} - -static void bad_macro1(void) -{ - m(); - a(); - r(); -} - -static void bad_macro2(void) -{ - a(); - r(); - m(); -} - -static void bad_macro3(void) -{ - r(); - a(); -} - -/* - * check-name: Check __context__ statement with required context - * - * check-error-start -context-statement.c:16:8: warning: context imbalance in 'bad_arr': unexpected unlock -context-statement.c:16:8: context 'LOCK': wanted 0, got -1 -context-statement.c:38:5: warning: context imbalance in 'bad_macro1': __context__ statement expected different context -context-statement.c:38:5: context 'LOCK': wanted >= 1, got 0 -context-statement.c:47:5: warning: context imbalance in 'bad_macro2': __context__ statement expected different context -context-statement.c:47:5: context 'LOCK': wanted >= 1, got 0 -context-statement.c:53:5: warning: context imbalance in 'bad_macro3': __context__ statement expected different context -context-statement.c:53:5: context 'LOCK': wanted >= 0, got -1 - * check-error-end - */ diff --git a/validation/context.c b/validation/context.c index 0b45ba3..4b15e75 100644 --- a/validation/context.c +++ b/validation/context.c @@ -314,109 +314,23 @@ static void warn_cond_lock1(void) condition2 = 1; /* do stuff */ r(); } - -static void warn_odd_looping(void) -{ - int i; - - for (i = 0; i < 2; i++) - a(); - for (i = 0; i < 2; i++) - r(); -} - -static void warn_huge_switch(void) -{ - a(); - - switch(condition) { - case 1: - r(); - break; - case 2: - r(); - break; - case 3: - r(); - break; - case 4: - r(); - break; - case 5: - r(); - break; - case 11: - r(); - break; - case 12: - r(); - break; - case 13: - r(); - break; - case 14: - r(); - case 15: - r(); - break; - case 16: - r(); - break; - case 17: - r(); - break; - } -} - -static int warn_conditional(void) -{ - if (condition) - return 0; - - a(); - if (condition == 0) - return 1; - r(); - return 0; -} - /* * check-name: Check -Wcontext * * check-error-start -context.c:71:3: warning: context imbalance in 'warn_lock1': wrong count at exit -context.c:71:3: default context: wanted 0, got 1 -context.c:78:3: warning: context imbalance in 'warn_lock2': wrong count at exit -context.c:78:3: default context: wanted 0, got 1 -context.c:85:3: warning: context imbalance in 'warn_lock3': wrong count at exit -context.c:85:3: default context: wanted 0, got 1 -context.c:90:3: warning: context problem in 'warn_unlock1': 'r' expected different context -context.c:90:3: default context: wanted >= 1, got 0 -context.c:97:3: warning: context problem in 'warn_unlock2': 'r' expected different context -context.c:97:3: default context: wanted >= 1, got 0 -context.c:137:9: warning: context imbalance in 'warn_if1': wrong count at exit -context.c:137:9: default context: wanted 0, got 1 -context.c:147:9: warning: context imbalance in 'warn_if2': wrong count at exit -context.c:147:9: default context: wanted 0, got 1 -context.c:203:4: warning: context imbalance in 'warn_while1': wrong count at exit -context.c:203:4: default context: wanted 0, got 1 -context.c:210:4: warning: context problem in 'warn_while2': 'r' expected different context -context.c:210:4: default context: wanted >= 1, got 0 -context.c:220:4: warning: context imbalance in 'warn_while3': wrong count at exit -context.c:220:4: default context: wanted 0, got 1 -context.c:280:5: warning: context imbalance in 'warn_goto1': wrong count at exit -context.c:280:5: default context: wanted 0, got 1 -context.c:290:6: warning: context imbalance in 'warn_goto2': wrong count at exit -context.c:290:6: default context: wanted 0, got 1 -context.c:300:6: warning: context problem in 'warn_goto3': 'r' expected different context -context.c:300:6: default context: wanted >= 1, got 0 -context.c:315:6: warning: context problem in 'warn_cond_lock1': 'r' expected different context -context.c:315:6: default context: wanted >= 1, got 0 -context.c:325:10: warning: context problem in 'warn_odd_looping': 'r' expected different context -context.c:325:10: default context: wanted >= 1, got 0 -context.c:360:10: warning: context problem in 'warn_huge_switch': 'r' expected different context -context.c:360:10: default context: wanted >= 1, got 0 -context.c:380:12: warning: context imbalance in 'warn_conditional': wrong count at exit -context.c:380:12: default context: wanted 0, got 1 +context.c:69:13: warning: context imbalance in 'warn_lock1' - wrong count at exit +context.c:74:13: warning: context imbalance in 'warn_lock2' - wrong count at exit +context.c:81:13: warning: context imbalance in 'warn_lock3' - wrong count at exit +context.c:88:13: warning: context imbalance in 'warn_unlock1' - unexpected unlock +context.c:93:13: warning: context imbalance in 'warn_unlock2' - unexpected unlock +context.c:131:12: warning: context imbalance in 'warn_if1' - wrong count at exit +context.c:140:12: warning: context imbalance in 'warn_if2' - different lock contexts for basic block +context.c:202:2: warning: context imbalance in 'warn_while1' - different lock contexts for basic block +context.c:210:3: warning: context imbalance in 'warn_while2' - unexpected unlock +context.c:216:2: warning: context imbalance in 'warn_while3' - wrong count at exit +context.c:274:13: warning: context imbalance in 'warn_goto1' - wrong count at exit +context.c:283:13: warning: context imbalance in 'warn_goto2' - wrong count at exit +context.c:300:5: warning: context imbalance in 'warn_goto3' - different lock contexts for basic block +context.c:315:5: warning: context imbalance in 'warn_cond_lock1' - different lock contexts for basic block * check-error-end */ |