]> git.proxmox.com Git - mirror_frr.git/blame - tools/coccinelle/hash_const.cocci
lib: hashing functions should take const arguments
[mirror_frr.git] / tools / coccinelle / hash_const.cocci
CommitLineData
d8b87afe
QY
1//
2// Transition hash key signatures to take their argument as const.
3// Does not handle headers or weirdly named hash functions.
4//
5@noconst disable optional_qualifier@
6identifier A;
7identifier func =~ ".*key$|.*key_make$|.*hash_make$|.*hash_keymake$|.*hash_key$|.*hash_key.*";
8@@
9
10- func (void *A)
11+ func (const void *A)
12 { ... }
13
14@ depends on noconst disable optional_qualifier @
15identifier noconst.A;
16identifier noconst.func;
17identifier b;
18type T;
19@@
20
21func( ... ) {
22<...
23- T b = A;
24+ const T b = A;
25...>
26 }
27
28@ depends on noconst disable optional_qualifier @
29identifier noconst.A;
30identifier noconst.func;
31identifier b;
32type T;
33@@
34
35func(...)
36 {
37<...
38- T b = (T) A;
39+ const T b = A;
40...>
41 }
42
43@ depends on noconst disable optional_qualifier @
44identifier noconst.A;
45identifier noconst.func;
46identifier b;
47type T;
48@@
49
50func(...)
51 {
52<...
53- T b;
54+ const T b;
55...
56 b = A;
57...>
58 }
59
60@ depends on noconst disable optional_qualifier @
61identifier noconst.A;
62identifier noconst.func;
63identifier b;
64type T;
65@@
66
67func(...)
68 {
69<...
70- T b;
71+ const T b;
72...
73- b = (T) A;
74+ b = A;
75...>
76 }