mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
scripts/coccinelle: ptr_ret: Add ternary operator version
Add a ternary operator version of the open-coded PTR_RET(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Michal Marek <mmarek@suse.cz>
This commit is contained in:
parent
8700d3cd7b
commit
3085897359
1 changed files with 26 additions and 0 deletions
|
@ -30,6 +30,13 @@ expression ptr;
|
|||
- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
|
||||
+ return PTR_RET(ptr);
|
||||
|
||||
@depends on patch@
|
||||
expression ptr;
|
||||
@@
|
||||
|
||||
- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
|
||||
+ PTR_RET(ptr)
|
||||
|
||||
@r1 depends on !patch@
|
||||
expression ptr;
|
||||
position p1;
|
||||
|
@ -44,6 +51,13 @@ position p2;
|
|||
|
||||
* if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
|
||||
|
||||
@r3 depends on !patch@
|
||||
expression ptr;
|
||||
position p3;
|
||||
@@
|
||||
|
||||
* IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0
|
||||
|
||||
@script:python depends on org@
|
||||
p << r1.p1;
|
||||
@@
|
||||
|
@ -57,6 +71,12 @@ p << r2.p2;
|
|||
|
||||
coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
|
||||
|
||||
@script:python depends on org@
|
||||
p << r3.p3;
|
||||
@@
|
||||
|
||||
coccilib.org.print_todo(p[0], "WARNING: PTR_RET can be used")
|
||||
|
||||
@script:python depends on report@
|
||||
p << r1.p1;
|
||||
@@
|
||||
|
@ -68,3 +88,9 @@ p << r2.p2;
|
|||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
|
||||
|
||||
@script:python depends on report@
|
||||
p << r3.p3;
|
||||
@@
|
||||
|
||||
coccilib.report.print_report(p[0], "WARNING: PTR_RET can be used")
|
||||
|
|
Loading…
Reference in a new issue