summaryrefslogtreecommitdiffstats
path: root/scripts/check-coding-style.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:54:46 +0000
commitcd7b005519ade8ab6c97fcb21590b71b7d1be6e3 (patch)
treec611a8d0cd5e8f68f41b8c2d16ba580e0f40a38d /scripts/check-coding-style.sh
parentInitial commit. (diff)
downloadlibrtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.tar.xz
librtr-cd7b005519ade8ab6c97fcb21590b71b7d1be6e3.zip
Adding upstream version 0.8.0.upstream/0.8.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/check-coding-style.sh')
-rwxr-xr-xscripts/check-coding-style.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/check-coding-style.sh b/scripts/check-coding-style.sh
new file mode 100755
index 0000000..5f1e3c3
--- /dev/null
+++ b/scripts/check-coding-style.sh
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+# ---HELP---
+# to check kernel coding style of file(s):
+# a) either pass a filename as cmdline parameter
+# b) run without cmdline parameters and check all non third-party code
+# ---HELP---
+
+READLINK=$(which greadlink)
+[ -z "$READLINK" ] && {
+ READLINK=$(which readlink)
+}
+SCRIPT_DIR=$(dirname "$($READLINK -f "$0")")
+SCRIPT_FILE="$SCRIPT_DIR/check-coding-files.txt"
+SOURCE_DIR_NAMES="rtrlib tools tests"
+EXIT_CODE=0
+if [ -z "$1" ] ; then
+ for dir in ${SOURCE_DIR_NAMES}; do
+ normalized_dir=$($READLINK -f "${SCRIPT_DIR}/../${dir}")
+ CHECKSOURCE+=" $(find ${normalized_dir} -name '*.c' -or -name '*.h')"
+ done
+else
+ CHECKSOURCE=$($READLINK -f "$1")
+fi
+cd $SCRIPT_DIR/..
+for i in $CHECKSOURCE; do
+ echo "> check coding style of $i ..."
+ IGNORE="PREFER_KERNEL_TYPES,CONST_STRUCT,OPEN_BRACE,SPDX_LICENSE_TAG,OPEN_ENDED_LINE,UNNECESSARY_PARENTHESES,PREFER_PRINTF,GLOBAL_INITIALISERS,PREFER_PACKED,BOOL_MEMBER,STATIC_CONST_CHAR_ARRAY,LONG_LINE_STRING"
+ if [[ $i == *"unittest"* ]]; then
+ IGNORE="${IGNORE},CAMELCASE"
+ fi
+ $SCRIPT_DIR/checkpatch.pl -f --strict --no-tree --terse --show-types \
+ --max-line-length 120 --ignore ${IGNORE} $i
+
+ if [ $? -ne "0" ]; then
+ EXIT_CODE=1
+ fi
+done
+
+exit $EXIT_CODE