lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240603113513.48045-1-amadeuszx.slawinski@linux.intel.com>
Date: Mon,  3 Jun 2024 13:35:13 +0200
From: Amadeusz Sławiński <amadeuszx.slawinski@...ux.intel.com>
To: Julia Lawall <Julia.Lawall@...ia.fr>,
	Nicolas Palix <nicolas.palix@...g.fr>
Cc: linux-kernel@...r.kernel.org,
	cocci@...ia.fr,
	Amadeusz Sławiński <amadeuszx.slawinski@...ux.intel.com>,
	Cezary Rojewski <cezary.rojewski@...el.com>
Subject: [PATCH] Coccinelle: Add api/list_move.cocci

Use list_move(_tail) rather than open coding it.

Reviewed-by: Cezary Rojewski <cezary.rojewski@...el.com>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@...ux.intel.com>
---
 scripts/coccinelle/api/list_move.cocci | 67 ++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 scripts/coccinelle/api/list_move.cocci

diff --git a/scripts/coccinelle/api/list_move.cocci b/scripts/coccinelle/api/list_move.cocci
new file mode 100644
index 0000000000000..c157a298cdf57
--- /dev/null
+++ b/scripts/coccinelle/api/list_move.cocci
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Use list_move or list_move_tail rather than list_del or list_del_init
+// followed by either list_add or list_add_tail.
+//
+// Copyright (c) 2023, Intel Corporation
+// Confidence: High
+// Options: --no-includes --include-headers
+//
+// Keywords: list_move, list_move_tail
+//
+
+virtual context
+virtual org
+virtual patch
+virtual report
+
+@...ve depends on !patch@
+expression E, H;
+position p;
+@@
+
+(
+- list_del@p(E);
+|
+- list_del_init@p(E);
+)
+- list_add(E, H);
++ list_move(E, H);
+
+@...ve_tail depends on !patch@
+expression E, H;
+position p;
+@@
+
+(
+- list_del@p(E);
+|
+- list_del_init@p(E);
+)
+- list_add_tail(E, H);
++ list_move_tail(E, H);
+
+@...ipt:python depends on report@
+p << rmove.p;
+@@
+
+coccilib.report.print_report(p[0], "WARNING opportunity for list_move()")
+
+@...ipt:python depends on org@
+p << rmove.p;
+@@
+
+coccilib.org.print_todo(p[0], "WARNING opportunity for list_move()")
+
+@...ipt:python depends on report@
+p << rmove_tail.p;
+@@
+
+coccilib.report.print_report(p[0], "WARNING opportunity for list_move_tail()")
+
+@...ipt:python depends on org@
+p << rmove_tail.p;
+@@
+
+coccilib.org.print_todo(p[0], "WARNING opportunity for list_move_tail()")
+
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ