blob: 4146822e21bc5c6bd84763da392a0c0316acf6c1 [file] [log] [blame]
Jordan Rosecd4db5c2014-08-20 16:58:03 +00001// 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
11int open(const char *, int, ...);
12int close(int fildes);
13
14void 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
21void 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}