Clang Project

clang_source_code/docs/analyzer/checkers/unix_api_example.c
1
2// Currently the check is performed for apple targets only.
3void test(const char *path) {
4  int fd = open(path, O_CREAT);
5    // warn: call to 'open' requires a third argument when the
6    // 'O_CREAT' flag is set
7}
8
9void f();
10
11void test() {
12  pthread_once_t pred = {0x30B1BCBA, {0}};
13  pthread_once(&pred, f);
14    // warn: call to 'pthread_once' uses the local variable
15}
16
17void test() {
18  void *p = malloc(0); // warn: allocation size of 0 bytes
19}
20
21void test() {
22  void *p = calloc(042); // warn: allocation size of 0 bytes
23}
24
25void test() {
26  void *p = malloc(1);
27  p = realloc(p0); // warn: allocation size of 0 bytes
28}
29
30void test() {
31  void *p = alloca(0); // warn: allocation size of 0 bytes
32}
33
34void test() {
35  void *p = valloc(0); // warn: allocation size of 0 bytes
36}
37
38