aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation/bad-check-access0.c
blob: 3c4c023f2f89b67a800d7f1a7e2e351d2e78e5ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#define SIZE	2
static int buf[SIZE];

static inline int swt(int i)
{
	switch (i) {
	case 0 ... (SIZE-1):
		return buf[i];
	default:
		return 0;
	}
}

static int switch_ok(void) { return swt(1); }
static int switch_ko(void) { return swt(2); }


static inline int cbr(int i, int p)
{
	if (p)
		return buf[i];
	else
		return 0;
}

static int branch_ok(int x) { return cbr(1, x != x); }
static int branch_ko(int x) { return cbr(2, x != x); }

/*
 * check-name: bad-check-access0
 */