From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 30 Sep 2025 18:24:19 +0200
The coccicheck operation modes are connected with data format requirements.
Take them better into account in the affected SmPL code.
* The mode “context” works without an extra position variable.
* The other two output modes should not be mixed with data according to
“context” information.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
See also:
[PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates
https://lore.kernel.org/cocci/7d46a1d1-f205-4751-9f7d-6a219be04801@nvidia.com/
scripts/coccinelle/misc/ptr_err_to_pe.cocci | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/coccinelle/misc/ptr_err_to_pe.cocci b/scripts/coccinelle/misc/ptr_err_to_pe.cocci
index f0bd658c7edb..fa93a6f2e3d2 100644
--- a/scripts/coccinelle/misc/ptr_err_to_pe.cocci
+++ b/scripts/coccinelle/misc/ptr_err_to_pe.cocci
@@ -12,13 +12,20 @@
virtual context, report, org
-@r@
+@depends on context@
+expression ptr;
+constant char[] fmt;
+identifier print_func;
+@@
+*print_func(..., fmt, ..., PTR_ERR(ptr), ...)
+
+@r depends on org || report@
expression ptr;
constant char[] fmt;
position p;
identifier print_func;
@@
-*print_func(..., fmt, ..., PTR_ERR@p(ptr), ...)
+ print_func(..., fmt, ..., PTR_ERR@p(ptr), ...)
@script:python depends on report@
p << r.p;
--
2.51.0