bugprone-spuriously-wake-up-functions.c
5.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// RUN: %check_clang_tidy %s bugprone-spuriously-wake-up-functions %t -- --
#define NULL 0
struct Node1 {
void *Node1;
struct Node1 *next;
};
typedef struct mtx_t {
} mtx_t;
typedef struct cnd_t {
} cnd_t;
struct timespec {};
int cnd_wait(cnd_t *cond, mtx_t *mutex){};
int cnd_timedwait(cnd_t *cond, mtx_t *mutex,
const struct timespec *time_point){};
struct Node1 list_c;
static mtx_t lock;
static cnd_t condition_c;
struct timespec ts;
void consume_list_element(void) {
if (list_c.next == NULL) {
if (0 != cnd_wait(&condition_c, &lock)) {
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
}
if (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
if (list_c.next == NULL && 0 != cnd_wait(&condition_c, &lock))
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
while (list_c.next == NULL) {
if (0 != cnd_wait(&condition_c, &lock)) {
}
}
while (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock)) {
}
while (list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
;
if (list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
if (list_c.next == NULL)
cnd_wait(&condition_c, &lock);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_wait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
while (list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
}
while (list_c.next == NULL)
cnd_wait(&condition_c, &lock);
do {
if (0 != cnd_wait(&condition_c, &lock)) {
}
} while (list_c.next == NULL);
do
if (0 != cnd_wait(&condition_c, &lock)) {
}
while (list_c.next == NULL);
do
if (0 != cnd_wait(&condition_c, &lock))
;
while (list_c.next == NULL);
do {
cnd_wait(&condition_c, &lock);
} while (list_c.next == NULL);
do
cnd_wait(&condition_c, &lock);
while (list_c.next == NULL);
for (;; list_c.next == NULL) {
if (0 != cnd_wait(&condition_c, &lock)) {
}
}
for (;; list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock)) {
}
for (;; list_c.next == NULL)
if (0 != cnd_wait(&condition_c, &lock))
;
for (;; list_c.next == NULL) {
cnd_wait(&condition_c, &lock);
}
for (;; list_c.next == NULL)
cnd_wait(&condition_c, &lock);
if (list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
}
if (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
if (list_c.next == NULL && 0 != cnd_timedwait(&condition_c, &lock, &ts))
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
;
while (list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
}
while (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
while (list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
if (list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
}
if (list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'cnd_timedwait' should be placed inside a while statement [bugprone-spuriously-wake-up-functions]
while (list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
}
while (list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
do {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
} while (list_c.next == NULL);
do
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
while (list_c.next == NULL);
do
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
while (list_c.next == NULL);
do {
cnd_timedwait(&condition_c, &lock, &ts);
} while (list_c.next == NULL);
do
cnd_timedwait(&condition_c, &lock, &ts);
while (list_c.next == NULL);
for (;; list_c.next == NULL) {
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
}
for (;; list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts)) {
}
for (;; list_c.next == NULL)
if (0 != cnd_timedwait(&condition_c, &lock, &ts))
;
for (;; list_c.next == NULL) {
cnd_timedwait(&condition_c, &lock, &ts);
}
for (;; list_c.next == NULL)
cnd_timedwait(&condition_c, &lock, &ts);
}
int main() { return 0; }