extra: move some code out of match_comparison()
[smatch.git] / validation / sm_switch.c
blob9d206643ee80122efa356dd5b37df1884f608f45
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 sm_switch.c
52 * check-known-to-fail
54 * check-output-start
55 sm_switch.c:38 func(25) error: potential null derefence 'a'.
56 sm_switch.c:39 func(26) error: potential null derefence 'b'.
57 * check-output-end