Coccinelle: Add api/list_move.cocci
PATCH 1/1 Coccinelle: Add api/list_move.cocci
Use list_move(_tail) rather than open coding it.
Reviewed-by Cezary Rojewski <[email protected]>
Signed-off-by Amadeusz Sławiński <[email protected]>
--- scripts/coccinelle/api/list_move.cocci | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 scripts/coccinelle/api/list_move.cocci
scripts/coccinelle/api/list_move.cocci new file +67 -0
@@ -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 + +@rmove 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); + +@rmove_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); + +@script:python depends on report@ +p << rmove.p; +@@ + +coccilib.report.print_report(p[0], "WARNING opportunity for list_move()") + +@script:python depends on org@ +p << rmove.p; +@@ + +coccilib.org.print_todo(p[0], "WARNING opportunity for list_move()") + +@script:python depends on report@ +p << rmove_tail.p; +@@ + +coccilib.report.print_report(p[0], "WARNING opportunity for list_move_tail()") + +@script:python depends on org@ +p << rmove_tail.p; +@@ + +coccilib.org.print_todo(p[0], "WARNING opportunity for list_move_tail()") +
Signature · 1 line
2.34.1