summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle/hash_const.cocci
blob: 9c53cb01fbfbc90dc643ffe3faf7cdf5d1342038 (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
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
69
70
71
72
73
74
75
76
//
// Transition hash key signatures to take their argument as const.
// Does not handle headers or weirdly named hash functions.
//
@noconst disable optional_qualifier@
identifier A;
identifier func =~ ".*key$|.*key_make$|.*hash_make$|.*hash_keymake$|.*hash_key$|.*hash_key.*";
@@

- func (void *A)
+ func (const void *A)
  { ... }

@ depends on noconst disable optional_qualifier @
identifier noconst.A;
identifier noconst.func;
identifier b;
type T;
@@

func( ... ) {
<...
-  T b = A;
+  const T b = A;
...>
  }

@ depends on noconst disable optional_qualifier @
identifier noconst.A;
identifier noconst.func;
identifier b;
type T;
@@

func(...)
  {
<...
-  T b = (T) A;
+  const T b = A;
...>
  }

@ depends on noconst disable optional_qualifier @
identifier noconst.A;
identifier noconst.func;
identifier b;
type T;
@@

func(...)
  {
<...
-  T b;
+  const T b;
...
   b = A;
...>
  }

@ depends on noconst disable optional_qualifier @
identifier noconst.A;
identifier noconst.func;
identifier b;
type T;
@@

func(...)
  {
<...
-  T b;
+  const T b;
...
-  b = (T) A;
+  b = A;
...>
  }