blob: 03b4a6390a69548b210a3444ee72ae1ecdaec4b2 [file] [log] [blame]
Gabor Horvath643dee92020-02-04 15:57:31 -08001// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.fuchsia.Lock -verify %s
Gabor Horvathe4f4a6c2020-02-04 15:44:57 -08002// expected-no-diagnostics
3typedef int spin_lock_t;
4
5void spin_lock(spin_lock_t *lock);
6int getCond();
7int spin_trylock(spin_lock_t *lock) {
8 if (getCond())
9 return 0;
10 return -1;
11}
12void spin_unlock(spin_lock_t *lock);
13
14spin_lock_t mtx;
15void no_crash() {
16 if (spin_trylock(&mtx) == 0)
17 spin_unlock(&mtx);
18}