0001 // SPDX-License-Identifier: GPL-2.0-only
0002 ///
0003 /// Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))
0004 ///
0005 // Confidence: High
0006 // Copyright: (C) 2009, 2010 Nicolas Palix, DIKU.
0007 // Copyright: (C) 2009, 2010 Julia Lawall, DIKU.
0008 // Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6.
0009 // URL: https://coccinelle.gitlabpages.inria.fr/website
0010 // Options:
0011 //
0012 // Keywords: ERR_PTR, PTR_ERR, ERR_CAST
0013 // Version min: 2.6.25
0014 //
0015
0016 virtual context
0017 virtual patch
0018 virtual org
0019 virtual report
0020
0021
0022 @ depends on context && !patch && !org && !report@
0023 expression x;
0024 @@
0025
0026 * ERR_PTR(PTR_ERR(x))
0027
0028 @ depends on !context && patch && !org && !report @
0029 expression x;
0030 @@
0031
0032 - ERR_PTR(PTR_ERR(x))
0033 + ERR_CAST(x)
0034
0035 @r depends on !context && !patch && (org || report)@
0036 expression x;
0037 position p;
0038 @@
0039
0040 ERR_PTR@p(PTR_ERR(x))
0041
0042 @script:python depends on org@
0043 p << r.p;
0044 x << r.x;
0045 @@
0046
0047 msg="WARNING ERR_CAST can be used with %s" % (x)
0048 msg_safe=msg.replace("[","@(").replace("]",")")
0049 coccilib.org.print_todo(p[0], msg_safe)
0050
0051 @script:python depends on report@
0052 p << r.p;
0053 x << r.x;
0054 @@
0055
0056 msg="WARNING: ERR_CAST can be used with %s" % (x)
0057 coccilib.report.print_report(p[0], msg)