1 // SPDX-License-Identifier: GPL-2.0-only
3 /// Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
6 // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
7 // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
8 // URL: http://coccinelle.lip6.fr/
9 // Options: --no-includes --include-headers
11 // Keywords: ERR_PTR, PTR_ERR, PTR_ERR_OR_ZERO
12 // Version min: 2.6.39
24 - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
25 + return PTR_ERR_OR_ZERO(ptr);
31 - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
32 + return PTR_ERR_OR_ZERO(ptr);
38 - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
39 + PTR_ERR_OR_ZERO(ptr)
41 @r1 depends on !patch@
46 * if@p1 (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
48 @r2 depends on !patch@
53 * if@p2 (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
55 @r3 depends on !patch@
60 * IS_ERR@p3(ptr) ? PTR_ERR(ptr) : 0
62 @script:python depends on org@
66 coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
69 @script:python depends on org@
73 coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
75 @script:python depends on org@
79 coccilib.org.print_todo(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
81 @script:python depends on report@
85 coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
87 @script:python depends on report@
91 coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")
93 @script:python depends on report@
97 coccilib.report.print_report(p[0], "WARNING: PTR_ERR_OR_ZERO can be used")