Browse Source

degesch: add static analysis for the logger

Caught two more occurences than I was able to find by just scanning
the source, so the effort wasn't in vain.
tags/v0.9.6
Přemysl Janouch 1 year ago
parent
commit
b1a89f313a
No known key found for this signature in database
2 changed files with 16 additions and 0 deletions
  1. 2
    0
      CMakeLists.txt
  2. 14
    0
      test-static

+ 2
- 0
CMakeLists.txt View File

@@ -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

+ 14
- 0
test-static View File

@@ -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

Loading…
Cancel
Save