expressions: make assign_expression() take an op argument
[smatch.git] / validation / sm_null_deref.c
blobdf399e6cc56899602f063a07c0d67bc3fe4cfab5
1 #include "check_debug.h"
3 struct foo {
4 int a;
5 };
7 struct foo *a;
8 struct foo *b;
9 struct foo *c;
10 struct foo *d;
12 static void func (void)
14 struct foo *aa;
15 int ab = 0;
16 int ac = 1;
18 aa->a = 1;
20 if (a) {
21 a->a = 1;
23 a->a = 1;
25 if (a && b) {
26 b->a = 1;
29 if (a || b) {
30 b->a = 1;
33 if (c) {
34 ab = 1;
37 if (ab) {
38 c->a = 1;
42 * check-name: Null Dereferences
43 * check-command: smatch --spammy -I.. sm_null_deref.c
45 * check-output-start
46 sm_null_deref.c:18 func() error: potentially dereferencing uninitialized 'aa'.
47 sm_null_deref.c:23 func() error: we previously assumed 'a' could be null (see line 20)
48 sm_null_deref.c:25 func() warn: variable dereferenced before check 'a' (see line 23)
49 sm_null_deref.c:30 func() error: we previously assumed 'b' could be null (see line 25)
50 * check-output-end