smatch_data/kernel.unreachable.ignore: add BUG(), WARN_ON() and others
[smatch.git] / validation / sm_switch.c
blobcd48c3d3ca1d727db63997526039f1708fb8c5af
1 //#include <stdlib.h>
3 struct foo {
4 int a;
5 };
7 struct foo *a;
8 struct foo *b;
9 struct foo *c;
10 struct foo *d;
11 int x;
13 void func (void)
15 a = 0;
16 b = 0;
17 c = 0;
18 d = 0;
20 switch(x) {
21 case 1:
22 a = returns_nonnull();
23 break;
24 case 2:
25 b = returns_nonnull();
26 break;
27 case 3:
28 c = returns_nonnull();
29 break;
30 default:
31 d = returns_nonnull();
34 switch(x) {
35 case 1:
36 a->a = 1;
37 case 2:
38 a->a = 2;
39 b->a = 3;
40 break;
41 case 3:
42 c->a = 4;
43 break;
44 case 4:
45 d->a = 5;
46 break;
50 * check-name: Smatch switch handling
51 * check-command: smatch --spammy sm_switch.c
52 * check-known-to-fail
54 * check-output-start
55 sm_switch.c:38 func() warn: missing break? reassigning 'a->a'
56 sm_switch.c:38 func() error: potential NULL dereference 'a'.
57 sm_switch.c:39 func() error: potential NULL dereference 'b'.
58 * check-output-end