From: shdown Date: Mon, 3 Aug 2015 09:51:39 +0000 (+0300) Subject: .travis.yml: add a wrapped functions grepper script X-Git-Tag: 4.11~58^2~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7ef3fdec00afa28505c207644c44cfc750faa9e0;p=i3%2Fi3 .travis.yml: add a wrapped functions grepper script --- diff --git a/.travis.yml b/.travis.yml index e3e45656..f90e0ebd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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