[master] 20f5c0432 Also check in return.cocci

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Apr 16 09:13:06 UTC 2019


commit 20f5c0432b274aaf9816a57e32bafbb0634c1aea
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Apr 16 11:11:45 2019 +0200

    Also check in return.cocci
    
    This one is much more tricky to use though, certainly not for
    automation purposes.

diff --git a/tools/coccinelle/return.cocci b/tools/coccinelle/return.cocci
new file mode 100644
index 000000000..50f877841
--- /dev/null
+++ b/tools/coccinelle/return.cocci
@@ -0,0 +1,35 @@
+/*
+ * Our code style inherited from FreeBSD explicitly requires brackets around a
+ * function's return (value). The trick is to always add the parenthesis and
+ * then undo the cases where we ended with two sets of them.
+ *
+ * It has the annoying effect of joining lines that were broken because of
+ * the same code style and this needs to be fixed by hand.
+ *
+ * This does not apply to lib/libvgz/ as this is mostly bundled code and one
+ * quick way to undo changes there after running this patch is:
+ *
+ *     git checkout -- lib/libvgz/
+ *
+ * Once libvgz is out of the way, one quick way to unbreak lines that had the
+ * parenthesis in place is:
+ *
+ *     git checkout --patch
+ *
+ * An interactive prompt will ask what to do for each hunk of updated code and
+ * replying 'y' to a false positive undoes the change on disk.
+ */
+
+@@
+expression rv;
+@@
+
+- return rv;
++ return (rv);
+
+@@
+expression rv;
+@@
+
+- return ((rv));
++ return (rv);


More information about the varnish-commit mailing list