summaryrefslogtreecommitdiffstats
path: root/tools/coccinelle
diff options
context:
space:
mode:
authorMark Stapp <mjs@voltanet.io>2020-09-22 18:02:28 +0200
committerMark Stapp <mjs@voltanet.io>2020-10-23 18:16:52 +0200
commit70c583eb819d93d8ec494880f4645be0f942c7a5 (patch)
treef1fa06053b4ea1f1ff3e2d25ecd7c90a223bf0a9 /tools/coccinelle
parent*: unify thread/event cancel macros (diff)
downloadfrr-70c583eb819d93d8ec494880f4645be0f942c7a5.tar.xz
frr-70c583eb819d93d8ec494880f4645be0f942c7a5.zip
tools: add cocci patch for thread cancel api changes
Add Quentin's cocci patch to align code with the changes to the event cancel api. Also added a README to explain what this collection of cocci patches is for. Signed-off-by: Quentin Young <qlyoung@nvidia.com> Signed-off-by: Mark Stapp <mjs@voltanet.io>
Diffstat (limited to 'tools/coccinelle')
-rw-r--r--tools/coccinelle/README.md14
-rw-r--r--tools/coccinelle/thread_cancel_api.cocci68
2 files changed, 82 insertions, 0 deletions
diff --git a/tools/coccinelle/README.md b/tools/coccinelle/README.md
new file mode 100644
index 000000000..262ccc1da
--- /dev/null
+++ b/tools/coccinelle/README.md
@@ -0,0 +1,14 @@
+Coccinelle patches
+==================
+
+This collection of coccinelle patches represents some of the broader,
+codebase-wide changes that have been made. If you maintain a fork of
+FRR and find that your codebase needs to be updated to align with
+these changes, the coccinelle tool should help you make that update.
+
+The coccinelle tool is documented at:
+ https://coccinelle.gitlabpages.inria.fr/website/
+
+To run a coccinelle patch script:
+
+ spatch --sp-file tools/coccinelle/semicolon.cocci zebra/*.c
diff --git a/tools/coccinelle/thread_cancel_api.cocci b/tools/coccinelle/thread_cancel_api.cocci
new file mode 100644
index 000000000..cc34f9389
--- /dev/null
+++ b/tools/coccinelle/thread_cancel_api.cocci
@@ -0,0 +1,68 @@
+@ptrupdate@
+expression E;
+@@
+- thread_cancel(E);
++ thread_cancel(&E);
+
+@nullcheckremove depends on ptrupdate@
+expression E;
+@@
+
+thread_cancel(&E);
+- E = NULL;
+
+@cancelguardremove depends on nullcheckremove@
+expression E;
+@@
+- if (E)
+- {
+ thread_cancel(&E);
+- }
+
+@cancelguardremove2 depends on nullcheckremove@
+expression E;
+@@
+- if (E != NULL)
+- {
+ thread_cancel(&E);
+- }
+
+@cancelguardremove3 depends on nullcheckremove@
+expression E;
+@@
+- if (E)
+ thread_cancel(&E);
+
+@cancelguardremove4 depends on nullcheckremove@
+expression E;
+@@
+- if (E != NULL)
+ thread_cancel(&E);
+
+@replacetimeroff@
+expression E;
+@@
+
+- THREAD_TIMER_OFF(E);
++ thread_cancel(&E);
+
+@replacewriteoff@
+expression E;
+@@
+
+- THREAD_WRITE_OFF(E);
++ thread_cancel(&E);
+
+@replacereadoff@
+expression E;
+@@
+
+- THREAD_READ_OFF(E);
++ thread_cancel(&E);
+
+@replacethreadoff@
+expression E;
+@@
+
+- THREAD_OFF(E);
++ thread_cancel(&E); \ No newline at end of file