*new* memset: check for memset(x, y, 0); typos
[smatch.git] / validation / sm_locking2.c
blob77414ee15b9f131345219a7eb292ee4074fb8642
1 void _spin_lock(int name);
2 void _spin_unlock(int name);
3 int _spin_trylock(int name);
5 int a;
6 int b;
7 int func (void)
9 int mylock = 1;
10 int mylock2 = 1;
11 int mylock3 = 1;
13 if (!_spin_trylock(mylock)) {
14 return;
17 _spin_unlock(mylock);
18 _spin_unlock(mylock2);
20 if (a)
21 _spin_unlock(mylock);
22 _spin_lock(mylock2);
24 if (!_spin_trylock(mylock3))
25 return;
26 return;
29 * check-name: Smatch locking #2
30 * check-command: smatch --project=kernel sm_locking2.c
32 * check-output-start
33 sm_locking2.c +21 func(14) error: double unlock 'spin_lock:mylock'
34 sm_locking2.c +26 func(19) warn: inconsistent returns spin_lock:mylock3: locked (26) unlocked (14,25)
35 * check-output-end