Jordan Rose | cd4db5c | 2014-08-20 16:58:03 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s |
| 2 | |
| 3 | #ifndef O_RDONLY |
| 4 | #define O_RDONLY 0 |
| 5 | #endif |
| 6 | |
| 7 | #ifndef NULL |
| 8 | #define NULL ((void*) 0) |
| 9 | #endif |
| 10 | |
| 11 | int open(const char *, int, ...); |
| 12 | int close(int fildes); |
| 13 | |
| 14 | void open_1(const char *path) { |
| 15 | int fd; |
| 16 | fd = open(path, O_RDONLY); // no-warning |
| 17 | if (fd > -1) |
| 18 | close(fd); |
| 19 | } |
| 20 | |
| 21 | void open_2(const char *path) { |
| 22 | int fd; |
| 23 | int mode = 0x0; |
| 24 | fd = open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' with more than three arguments}} |
| 25 | if (fd > -1) |
| 26 | close(fd); |
| 27 | } |