Thread (7 messages) 7 messages, 1 author, 2025-09-30
DORMANTno replies

[PATCH 6/6] Coccinelle: ptr_err_to_pe: Distinguish implementation details better for operation mode properties

From: Markus Elfring <hidden>
Date: 2025-09-30 17:45:28
Also in: cocci, linux-rdma, lkml
Subsystem: coccinelle/semantic patches (smpl), the rest · Maintainers: Julia Lawall, Nicolas Palix, Linus Torvalds

From: Markus Elfring <redacted>
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 <redacted>
---
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/ (local)


 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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help