From e4655196e21fdfb3a3c60e930d48b97a9f3ec693 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 15 Apr 2024 21:15:18 +0000 Subject: [PATCH 1/2] coccinelle: misc: minmax: Suppress reports for err returns Most of the people prefer: return ret < 0 ? ret: 0; than: return min(ret, 0); Let's tweak the cocci file to ignore those lines completely. Signed-off-by: Ricardo Ribalda Signed-off-by: Julia Lawall --- scripts/coccinelle/misc/minmax.cocci | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/coccinelle/misc/minmax.cocci b/scripts/coccinelle/misc/minmax.cocci index fcf908b34f27..ca4830ae3042 100644 --- a/scripts/coccinelle/misc/minmax.cocci +++ b/scripts/coccinelle/misc/minmax.cocci @@ -50,11 +50,26 @@ func(...) ...> } +// Ignore errcode returns. +@errcode@ +position p; +identifier func; +expression x; +binary operator cmp = {<, <=}; +@@ + +func(...) +{ + <... + return ((x) cmp@p 0 ? (x) : 0); + ...> +} + @rmin depends on !patch@ identifier func; expression x, y; binary operator cmp = {<, <=}; -position p; +position p != errcode.p; @@ func(...) @@ -116,21 +131,6 @@ func(...) ...> } -// Don't generate patches for errcode returns. -@errcode depends on patch@ -position p; -identifier func; -expression x; -binary operator cmp = {<, <=}; -@@ - -func(...) -{ - <... - return ((x) cmp@p 0 ? (x) : 0); - ...> -} - @pmin depends on patch@ identifier func; expression x, y; From 88a1fc21df74514bb3a3ae88b89cf1272c7c0c6e Mon Sep 17 00:00:00 2001 From: Thorsten Blum Date: Sat, 11 May 2024 23:31:19 +0200 Subject: [PATCH 2/2] Coccinelle: pm_runtime: Fix grammar in comment s/does not use unnecessary/do not unnecessarily use/ Signed-off-by: Thorsten Blum Signed-off-by: Julia Lawall --- scripts/coccinelle/api/pm_runtime.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/coccinelle/api/pm_runtime.cocci b/scripts/coccinelle/api/pm_runtime.cocci index 4b9778874453..2c931e748dda 100644 --- a/scripts/coccinelle/api/pm_runtime.cocci +++ b/scripts/coccinelle/api/pm_runtime.cocci @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/// Make sure pm_runtime_* calls does not use unnecessary IS_ERR_VALUE +/// Make sure pm_runtime_* calls do not unnecessarily use IS_ERR_VALUE /// // Keywords: pm_runtime // Confidence: Medium