1 | // RUN: %check_clang_tidy %s android-cloexec-accept %t |
2 | |
3 | struct sockaddr {}; |
4 | typedef int socklen_t; |
5 | #define NULL 0 |
6 | |
7 | extern "C" int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
8 | |
9 | void f() { |
10 | accept(sockfd: 0, NULL, NULL); |
11 | // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer accept4() to accept() because accept4() allows SOCK_CLOEXEC [android-cloexec-accept] |
12 | // CHECK-FIXES: accept4(0, NULL, NULL, SOCK_CLOEXEC); |
13 | } |
14 | |
15 | namespace i { |
16 | int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
17 | void g() { |
18 | accept(sockfd: 0, NULL, NULL); |
19 | } |
20 | } // namespace i |
21 | |
22 | class C { |
23 | public: |
24 | int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
25 | void h() { |
26 | accept(sockfd: 0, NULL, NULL); |
27 | } |
28 | }; |
29 | |