diff options
| author | Jordan Rose <jordan_rose@apple.com> | 2014-08-20 16:58:03 +0000 |
|---|---|---|
| committer | Jordan Rose <jordan_rose@apple.com> | 2014-08-20 16:58:03 +0000 |
| commit | cd4db5c6d2993fcb0d0836032a4637b8f8eabb62 (patch) | |
| tree | 5b786626353cce3301dd459412fd5a8eb1b2a739 /clang/test/Analysis/unix-api.c | |
| parent | b6fd112b760404209e6ed959df8f964c9c273f78 (diff) | |
| download | bcm5719-llvm-cd4db5c6d2993fcb0d0836032a4637b8f8eabb62.tar.gz bcm5719-llvm-cd4db5c6d2993fcb0d0836032a4637b8f8eabb62.zip | |
[analyzer] UnixAPI: Check when open(2) is called with more than three arguments.
Patch by Daniel Fahlgren.
llvm-svn: 216078
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); +} |

