1 | // RUN: %check_clang_tidy %s android-cloexec-epoll-create1 %t |
---|---|
2 | |
3 | #define __O_CLOEXEC 3 |
4 | #define EPOLL_CLOEXEC __O_CLOEXEC |
5 | #define TEMP_FAILURE_RETRY(exp) \ |
6 | ({ \ |
7 | int _rc; \ |
8 | do { \ |
9 | _rc = (exp); \ |
10 | } while (_rc == -1); \ |
11 | }) |
12 | |
13 | extern "C"int epoll_create1(int flags); |
14 | |
15 | void a() { |
16 | epoll_create1(flags: 0); |
17 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1' should use EPOLL_CLOEXEC where possible [android-cloexec-epoll-create1] |
18 | // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC); |
19 | TEMP_FAILURE_RETRY(epoll_create1(0)); |
20 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1' |
21 | // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC)); |
22 | } |
23 | |
24 | void f() { |
25 | epoll_create1(flags: 3); |
26 | // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'epoll_create1' |
27 | // CHECK-FIXES: epoll_create1(EPOLL_CLOEXEC); |
28 | TEMP_FAILURE_RETRY(epoll_create1(3)); |
29 | // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: 'epoll_create1' |
30 | // CHECK-FIXES: TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC)); |
31 | |
32 | int flag = 0; |
33 | epoll_create1(EPOLL_CLOEXEC); |
34 | TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC)); |
35 | } |
36 | |
37 | namespace i { |
38 | int epoll_create1(int flags); |
39 | |
40 | void d() { |
41 | epoll_create1(flags: 0); |
42 | TEMP_FAILURE_RETRY(epoll_create1(0)); |
43 | } |
44 | |
45 | } // namespace i |
46 | |
47 | void e() { |
48 | epoll_create1(EPOLL_CLOEXEC); |
49 | TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC)); |
50 | } |
51 | |
52 | class G { |
53 | public: |
54 | int epoll_create1(int flags); |
55 | void d() { |
56 | epoll_create1(EPOLL_CLOEXEC); |
57 | TEMP_FAILURE_RETRY(epoll_create1(EPOLL_CLOEXEC)); |
58 | } |
59 | }; |
60 |