xref: /illumos-gate/usr/src/tools/smatch/src/validation/sm_locking3.c (revision d45f07cb8d28ca0e38cd96d8f00243ba58192eec)
1 int _spin_trylock(int name);
2 void _spin_lock(int name);
3 void _spin_unlock(int name);
4 
5 int func (void)
6 {
7 	int mylock = 1;
8 
9 	if (!({frob(); frob(); _spin_trylock(mylock);}))
10 		return;
11 
12 	frob();
13 	_spin_unlock(mylock);
14 
15 	if (((_spin_trylock(mylock)?1:0)?1:0))
16 		return;
17 	frob_somemore();
18 	_spin_unlock(mylock);
19 
20 	return;
21 }
22 /*
23  * check-name: Smatch locking #3
24  * check-command: smatch --project=kernel sm_locking3.c
25  *
26  * check-output-start
27 sm_locking3.c:18 func() error: double unlocked 'mylock' (orig line 15)
28 sm_locking3.c:20 func() warn: inconsistent returns 'mylock'.
29   Locked on  : 16
30   Unlocked on: 10,20
31  * check-output-end
32  */
33