1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.API -verify %s
8 #define NULL ((void*) 0)
11 int open(const char *, int, ...);
12 int openat(int, const char *, int, ...);
13 int close(int fildes
);
15 void open_1(const char *path
) {
17 fd
= open(path
, O_RDONLY
); // no-warning
22 void open_2(const char *path
) {
25 fd
= open(path
, O_RDONLY
, mode
, NULL
); // expected-warning{{Call to 'open' with more than 3 arguments}}
30 void openat_2(int base_fd
, const char *path
) {
33 fd
= openat(base_fd
, path
, O_RDONLY
, mode
, NULL
); // expected-warning{{Call to 'openat' with more than 4 arguments}}
38 void open_3(const char *path
) {
40 fd
= open(path
, O_RDONLY
, NULL
); // expected-warning{{The 3rd argument to 'open' is not an integer}}
45 void openat_3(int base_fd
, const char *path
) {
47 fd
= openat(base_fd
, path
, O_RDONLY
, NULL
); // expected-warning{{The 4th argument to 'openat' is not an integer}}
53 void open_4(const char *path
) {
55 fd
= open(path
, O_RDONLY
, ""); // expected-warning{{The 3rd argument to 'open' is not an integer}}
60 void open_5(const char *path
) {
65 fd
= open(path
, O_RDONLY
, st
); // expected-warning{{The 3rd argument to 'open' is not an integer}}
70 void open_6(const char *path
) {
75 fd
= open(path
, O_RDONLY
, st
.val
); // no-warning
80 void open_7(const char *path
) {
82 fd
= open(path
, O_RDONLY
, &open
); // expected-warning{{The 3rd argument to 'open' is not an integer}}
87 void open_8(const char *path
) {
89 fd
= open(path
, O_RDONLY
, 0.0f
); // expected-warning{{The 3rd argument to 'open' is not an integer}}