Skip to content

Commit 6f98ae3

Browse files
himanshujha199640nashif
authored andcommitted
coccinelle: irq_lock.cocci: Update script
* Provide a single liner description at top using `///` comments. This one liner is displayed when using `--verbose` mode of coccicheck. * Specify Condidence level property adhering to coccinelle.rst section "Proposing new semantic patches". * Add virtual patch rule to handle the patch case when coccicheck is supplied with `--mode=patch` option. * Add `depends on !(file in "ext")` to ignore reports from `ext/` directory. * Simplify rule to use disjunctions and use "exists" to match any available control path. Suggested-by: Julia Lawall <[email protected]> Signed-off-by: Himanshu Jha <[email protected]>
1 parent ff5a8a8 commit 6f98ae3

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

scripts/coccinelle/irq_lock.cocci

+31-33
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1+
/// Use unsigned int as the return value for irq_lock()
2+
///
3+
// Confidence: High
14
// Copyright (c) 2017 Intel Corporation
25
//
36
// SPDX-License-Identifier: Apache-2.0
47

5-
@find@
8+
virtual patch
9+
10+
@find depends on !(file in "ext")@
611
type T;
7-
position p;
812
identifier i;
13+
typedef uint32_t,u32_t;
914
@@
1015

11-
T@p i = irq_lock();
12-
13-
@script:python raise_error@
14-
t << find.T;
15-
@@
16-
if t in ["uint32_t", "unsigned int", "u32_t"]:
17-
cocci.include_match(False)
18-
19-
@replacement@
20-
type find.T;
21-
position find.p;
22-
@@
23-
- T@p
16+
(
17+
uint32_t i = irq_lock();
18+
|
19+
unsigned int i = irq_lock();
20+
|
21+
u32_t i = irq_lock();
22+
|
23+
- T
2424
+ unsigned int
25+
i = irq_lock();
26+
)
2527

26-
@find2@
28+
@find2 depends on !(file in "ext") exists@
2729
type T;
28-
position p;
2930
identifier i;
3031
@@
3132

32-
T@p i;
33-
...
34-
i = irq_lock();
35-
36-
@script:python raise_error2@
37-
t << find2.T;
38-
@@
39-
if t in ["uint32_t", "unsigned int", "u32_t"]:
40-
cocci.include_match(False)
41-
42-
@replacement2@
43-
type find2.T;
44-
identifier find2.i;
45-
@@
46-
- T i;
47-
+ unsigned int i;
33+
(
34+
uint32_t i;
35+
|
36+
unsigned int i;
37+
|
38+
u32_t i;
39+
|
40+
- T
41+
+ unsigned int
42+
i;
43+
...
44+
i = irq_lock();
45+
)

0 commit comments

Comments
 (0)