Print this page
11506 smatch resync
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/tools/smatch/src/validation/sm_null_deref.c
+++ new/usr/src/tools/smatch/src/validation/sm_null_deref.c
1 1 #include "check_debug.h"
2 2
3 3 struct foo {
4 4 int a;
5 5 };
6 6
7 7 struct foo *a;
8 8 struct foo *b;
9 9 struct foo *c;
10 10 struct foo *d;
11 11
12 12 static void func (void)
13 13 {
14 14 struct foo *aa;
15 15 int ab = 0;
16 16 int ac = 1;
17 17
18 18 aa->a = 1;
19 19
20 20 if (a) {
21 21 a->a = 1;
22 22 }
23 23 a->a = 1;
24 24
25 25 if (a && b) {
26 26 b->a = 1;
27 27 }
28 28
29 29 if (a || b) {
30 30 b->a = 1;
31 31 }
32 32
33 33 if (c) {
34 34 ab = 1;
35 35 }
36 36
↓ open down ↓ |
36 lines elided |
↑ open up ↑ |
37 37 if (ab) {
38 38 c->a = 1;
39 39 }
40 40 }
41 41 /*
42 42 * check-name: Null Dereferences
43 43 * check-command: smatch --spammy -I.. sm_null_deref.c
44 44 *
45 45 * check-output-start
46 46 sm_null_deref.c:18 func() error: potentially dereferencing uninitialized 'aa'.
47 +sm_null_deref.c:18 func() error: potentially dereferencing uninitialized 'aa'.
47 48 sm_null_deref.c:23 func() error: we previously assumed 'a' could be null (see line 20)
48 49 sm_null_deref.c:25 func() warn: variable dereferenced before check 'a' (see line 23)
49 50 sm_null_deref.c:30 func() error: we previously assumed 'b' could be null (see line 25)
50 51 * check-output-end
51 52 */
52 53
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX