.travis.yml: add a wrapped functions grepper script

This commit is contained in:
shdown 2015-08-03 12:51:39 +03:00
parent fa4f1c5b0f
commit 7ef3fdec00
1 changed files with 19 additions and 0 deletions

View File

@ -45,3 +45,22 @@ script:
- CFLAGS="-Wformat -Wformat-security -Wextra -Wno-unused-parameter -Werror" make -j
- (cd testcases && xvfb-run ./complete-run.pl --parallel=1 || (cat latest/complete-run.log; false))
- clang-format-3.5 -i $(find . -name "*.[ch]" | tr '\n' ' ') && git diff --exit-code || (echo 'Code was not formatted using clang-format!'; false)
- |
funcs='malloc|calloc|realloc|strdup|strndup|asprintf|write'
cstring='"([^"\\]|\\.)*"'
cchar="'[^\\\\]'|'\\\\.[^']*'"
regex="^([^'\"]|${cstring}|${cchar})*\<(${funcs})\>"
detected=0
while IFS= read -r file; do
if { cpp -w -fpreprocessed "$file" || exit "$?"; } | grep -E -- "$regex"; then
echo "^ $file calls a function that has a safe counterpart."
detected=1
fi
done << EOF
$(find -name '*.c' -not -name safewrappers.c -not -name strndup.c)
EOF
if [ "$detected" -ne 0 ]; then
echo
echo "Calls of functions that have safe counterparts were detected."
exit 1
fi