aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-09-25 14:13:44 +0300
committerGeorge Kadianakis <desnacked@riseup.net>2019-09-25 14:13:44 +0300
commite77ad795c68f28e8431dc5b098fba05fcec49c19 (patch)
tree38bc0ec0593dda3befb2aa11d2c45fa9e33b24ee /scripts
parent99f75373def3520fac4f00c072748f2a0886c923 (diff)
parent387cfccee47394adeba8cbf49c130cc9b332b025 (diff)
downloadtor-e77ad795c68f28e8431dc5b098fba05fcec49c19.tar.gz
tor-e77ad795c68f28e8431dc5b098fba05fcec49c19.zip
Merge branch 'tor-github/pr/1322'
Diffstat (limited to 'scripts')
-rw-r--r--scripts/coccinelle/debugmm.cocci29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/coccinelle/debugmm.cocci b/scripts/coccinelle/debugmm.cocci
new file mode 100644
index 0000000000..dbd308df33
--- /dev/null
+++ b/scripts/coccinelle/debugmm.cocci
@@ -0,0 +1,29 @@
+// Look for use of expressions with side-effects inside of debug logs.
+//
+// This script detects expressions like ++E, --E, E++, and E-- inside of
+// calls to log_debug().
+//
+// The log_debug() macro exits early if debug logging is not enabled,
+// potentially causing problems if its arguments have side-effects.
+
+@@
+expression E;
+@@
+*log_debug(... , <+... --E ...+>, ... );
+
+
+@@
+expression E;
+@@
+*log_debug(... , <+... ++E ...+>, ... );
+
+@@
+expression E;
+@@
+*log_debug(... , <+... E-- ...+>, ... );
+
+
+@@
+expression E;
+@@
+*log_debug(... , <+... E++ ...+>, ... );