aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rwxr-xr-xtest-static14
2 files changed, 16 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5152bb6..0af2dcd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -180,6 +180,8 @@ endfunction (make_tests_for)
include (CTest)
if (BUILD_TESTING)
make_tests_for (degesch)
+ add_test (NAME custom-static-analysis
+ COMMAND ${PROJECT_SOURCE_DIR}/test-static)
endif (BUILD_TESTING)
# Various clang-based diagnostics, loads of fake positives and spam
diff --git a/test-static b/test-static
new file mode 100755
index 0000000..0c22b0d
--- /dev/null
+++ b/test-static
@@ -0,0 +1,14 @@
+#!/bin/sh
+# We don't use printf's percent notation with our custom logging mechanism,
+# so the compiler cannot check it for us like it usually does
+perl -n0777 - "$(dirname "$0")"/degesch.c <<-'END'
+ while (/\blog_[^ ]+\s*\([^"()]*"[^"]*%[^%][^"]*"/gm) {
+ my ($p, $m) = ($`, $&);
+ printf "$ARGV:%d: suspicious log format string: %s...\n",
+ (1 + $p =~ tr/\n//), ($m =~ s/\s+/ /rg);
+ $status = 1;
+ }
+ END {
+ exit $status;
+ }
+END