[master] 328f3ab34 cocci: Match miniobj assertions in panic code

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Fri May 17 09:20:12 UTC 2024


commit 328f3ab3465ab7609ace8e2dcff267b8d769c27d
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri May 17 11:04:27 2024 +0200

    cocci: Match miniobj assertions in panic code

diff --git a/tools/coccinelle/panic_assert.cocci b/tools/coccinelle/panic_assert.cocci
new file mode 100644
index 000000000..760c54a0c
--- /dev/null
+++ b/tools/coccinelle/panic_assert.cocci
@@ -0,0 +1,42 @@
+/*
+ * This patch replaces a non-exhaustive list of statements designed to trigger
+ * assertions with something more appropriate for panic code.
+ *
+ * The heuristics for panic functions include:
+ * - something panic-related in the name
+ * - taking a VSB
+ * - returning void
+ */
+
+ at panic@
+identifier sb, func =~ "(^PAN_|^pan_|_panic$)";
+@@
+
+void func(..., struct vsb *sb, ...) { ... }
+
+@@
+identifier panic.sb, panic.func;
+expression obj, magicval;
+@@
+
+func(...)
+{
+...
+- CHECK_OBJ_NOTNULL(obj, magicval);
++ PAN_CheckMagic(sb, obj, magicval);
+...
+}
+
+@@
+identifier panic.sb, panic.func;
+expression obj, from, magicval;
+@@
+
+func(...)
+{
+...
+- CAST_OBJ_NOTNULL(obj, from, magicval);
++ obj = from;
++ PAN_CheckMagic(sb, obj, magicval);
+...
+}


More information about the varnish-commit mailing list