Skip to content

Commit

Permalink
Grep simple mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed Dec 19, 2022
1 parent c108d90 commit dd51e42
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions codebuild/bin/grep_simple_mistakes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ for dir in $S2N_ERROR_IF_FREE; do
done
done

#############################################

#############################################
## Assert all ".[c|h]" source files have the correct file mode.
#############################################
Expand All @@ -191,6 +189,17 @@ if [[ -n $S2N_FILES_WITH_WRONG_MODE ]]; then
printf "\\033[31;1mPlease run \`find s2n-tls/ -name '*.c' -o -name '*.h' -exec chmod 644 {} \\;\` to fix all file modes.\\033[0m\\n"
fi

#############################################
## Assert "extern" is not added to function declarations unnecessarily.
#############################################
S2N_FILES_ASSERT_NO_UNNECESSARY_EXTERNS=$(find "$PWD" -type f -name "s2n*.[h]" \! -path "*/api/*" \! -path "*/bindings/*")
S2N_UNNECESSARY_EXTERNS=$(grep -REs "extern (.*?) (.*?)\(" $S2N_FILES_ASSERT_NO_UNNECESSARY_EXTERNS)
if [[ -n $S2N_UNNECESSARY_EXTERNS ]]; then
FAILED=1
echo "Found unnecessary 'extern' in function declaration"
echo "$S2N_UNNECESSARY_EXTERNS"
fi

if [ $FAILED == 1 ]; then
printf "\\033[31;1mFAILED Grep For Simple Mistakes check\\033[0m\\n"
exit -1
Expand Down

0 comments on commit dd51e42

Please sign in to comment.