extra: fix a bug in how pointers are set inside called functions
[smatch.git] / validation / sm_locking6.c
blob1ac4816c971e462fe5e80ea29fce4e7f48b06013
1 int __raw_local_irq_save();
2 int _spin_trylock(int x);
3 int raw_local_irq_restore(flags);
5 #define spin_trylock_irqsave(lock, flags) \
6 ({ \
7 (flags) = __raw_local_irq_save(); \
8 _spin_trylock(lock) ? 1 : ({ raw_local_irq_restore(flags); 0; }); \
9 })
11 void _spin_unlock_irqrestore(int lock, int flags);
13 int zzz;
15 void func (void)
17 int lock = 1;
18 int flags = 1;
20 if (!spin_trylock_irqsave(lock, flags))
21 return;
22 _spin_unlock_irqrestore(lock, flags);
23 if (zzz)
24 return;
25 if (spin_trylock_irqsave(lock, flags))
26 return;
27 return;
30 * check-name: Smatch locking #6
31 * check-command: smatch -p=kernel sm_locking6.c
33 * check-output-start
34 sm_locking6.c:27 func() warn: inconsistent returns irqsave:flags: locked (26) unlocked (21,24,27)
35 sm_locking6.c:27 func() warn: inconsistent returns spin_lock:lock: locked (26) unlocked (21,24,27)
36 * check-output-end