[PATCH 3/6] Coccinelle: ptr_err_to_pe: Restrict the metavariable type “constant” for the usage of string literals

From: Markus Elfring

Date: Tue Sep 30 2025 - 13:37:09 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 30 Sep 2025 17:28:20 +0200

Refine the metavariable type “constant” with “char[]” so that only
string literals should be found for the desired source code search.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
See also:
[PATCH net-next 1/2] scripts/coccinelle: Find PTR_ERR() to %pe candidates
https://lore.kernel.org/cocci/6b2eb2c2-15e7-49b4-aaca-6fd58af9ec6c@xxxxxxxxxx/


scripts/coccinelle/misc/ptr_err_to_pe.cocci | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/coccinelle/misc/ptr_err_to_pe.cocci b/scripts/coccinelle/misc/ptr_err_to_pe.cocci
index 26888d2c9c83..fb4b5bf91081 100644
--- a/scripts/coccinelle/misc/ptr_err_to_pe.cocci
+++ b/scripts/coccinelle/misc/ptr_err_to_pe.cocci
@@ -14,7 +14,7 @@ virtual context, report, org

@r@
expression ptr;
-constant fmt;
+constant char[] fmt;
position p;
identifier print_func;
@@
--
2.51.0