File: data.c

package info (click to toggle)
cppcheck 1.86-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 14,600 kB
  • sloc: cpp: 169,157; python: 6,329; ansic: 3,848; xml: 847; makefile: 563; sh: 429; cs: 291
file content (68 lines) | stat: -rw-r--r-- 988 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

int TestData[10];

int g;
void global() {
  g = 1000;
  TestData[g] = 0; // BUG
}

int garr[10];
void global_array() {
  garr[3] = 1000;
  TestData[garr[3]] = 0; // BUG
}

int *gp;
void global_pointer() {
  *gp = 1000;
  TestData[*gp] = 0; // BUG
}


void local() {
  int x;
  x = 1000;
  TestData[x] = 0; // BUG
}

void local_array() {
  int arr[10];
  arr[3] = 1000;
  TestData[arr[3]] = 0; // BUG
}

void local_alias_1() {
  int x;
  int *p = &x;
  *p = 1000;
  TestData[*p] = 0; // BUG
}

void local_alias_2() {
  int x;
  int *p = &x;
  x = 1000;
  TestData[*p] = 0; // BUG
}

struct ABC {
  int a;
  int b[10];
  int c;
};

void struct_member_init() {
  struct ABC abc = {1000,{0},3};
  TestData[abc.a] = 0; // BUG
}

void struct_member_assign(struct ABC *abc) {
  abc->a = 1000;
  TestData[abc->a] = 0; // BUG
}

void struct_arraymember(struct ABC *abc) {
  abc->b[3] = 1000;
  TestData[abc->b[3]] = 0; // BUG
}