Skip to content

Commit 4eb42bf

Browse files
committed
Standardize naming and indentation
Renamed function for consistency and adjusted indentation to align with project style. Change-Id: I63df0cb1ad09288a426e9ac97bbcfe8ebe7ae764
1 parent 267d42f commit 4eb42bf

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

scripts/pre-commit.hook

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,25 @@ cppcheck_suppressions() {
6868
printf "%s" "$out" | sed 's/[[:space:]]*$//'
6969
}
7070

71-
# Check compiler type and __STDC_VERSION__
72-
get_compiler_macros() {
73-
local STDC_VERSION=""
74-
local EXTRA_DEFINES=""
75-
if command -v gcc >/dev/null 2>&1; then
76-
STDC_VERSION=$(gcc -dM -E -xc /dev/null | awk '/__STDC_VERSION__/ {print $3}')
77-
EXTRA_DEFINES="-D__GNUC__=1"
78-
elif command -v clang >/dev/null 2>&1; then
79-
STDC_VERSION=$(clang -dM -E -xc /dev/null | awk '/__STDC_VERSION__/ {print $3}')
80-
EXTRA_DEFINES="-D__clang__=1"
81-
fi
82-
if [ -n "$STDC_VERSION" ]; then
83-
EXTRA_DEFINES+=" -D__STDC__=1 -D__STDC_VERSION__=${STDC_VERSION}"
84-
fi
85-
echo "$EXTRA_DEFINES"
71+
# Generation of standard compliance for GCC/Clang
72+
detect_cc_std() {
73+
local STDC_VERSION=""
74+
local EXTRA_DEFINES=""
75+
if command -v gcc >/dev/null 2>&1; then
76+
STDC_VERSION=$(gcc -dM -E -xc /dev/null | awk '/__STDC_VERSION__/ {print $3}')
77+
EXTRA_DEFINES="-D__GNUC__=1"
78+
elif command -v clang >/dev/null 2>&1; then
79+
STDC_VERSION=$(clang -dM -E -xc /dev/null | awk '/__STDC_VERSION__/ {print $3}')
80+
EXTRA_DEFINES="-D__clang__=1"
81+
fi
82+
if [ -n "$STDC_VERSION" ]; then
83+
EXTRA_DEFINES+=" -D__STDC__=1 -D__STDC_VERSION__=${STDC_VERSION}"
84+
fi
85+
echo "$EXTRA_DEFINES"
8686
}
8787

8888
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1"
89-
CPPCHECK_OPTS+=" $(get_compiler_macros)"
89+
CPPCHECK_OPTS+=" $(detect_cc_std)"
9090
CPPCHECK_OPTS+=" --force $(cppcheck_suppressions) $(cppcheck_build_unmatched)"
9191
CPPCHECK_OPTS+=" --cppcheck-build-dir=.out ."
9292

0 commit comments

Comments
 (0)