diff options
Diffstat (limited to 'clang/test/Analysis/unix-api.c')
| -rw-r--r-- | clang/test/Analysis/unix-api.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/Analysis/unix-api.c b/clang/test/Analysis/unix-api.c new file mode 100644 index 00000000000..4146822e21b --- /dev/null +++ b/clang/test/Analysis/unix-api.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.API -verify %s + +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#ifndef NULL +#define NULL ((void*) 0) +#endif + +int open(const char *, int, ...); +int close(int fildes); + +void open_1(const char *path) { + int fd; + fd = open(path, O_RDONLY); // no-warning + if (fd > -1) + close(fd); +} + +void open_2(const char *path) { + int fd; + int mode = 0x0; + fd = open(path, O_RDONLY, mode, NULL); // expected-warning{{Call to 'open' with more than three arguments}} + if (fd > -1) + close(fd); +} |

