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

Markus Elfring posted 6 patches 1 day, 3 hours ago
[PATCH 3/6] Coccinelle: ptr_err_to_pe: Restrict the metavariable type “constant” for the usage of string literals
Posted by Markus Elfring 1 day, 3 hours ago
From: Markus Elfring <elfring@users.sourceforge.net>
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@users.sourceforge.net>
---
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@nvidia.com/


 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