aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-11 05:26:04 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-11 15:50:29 +0200
commit502498c4fc05ae9eaaf3db6014f38d0033085859 (patch)
treec0a882ebd596d5f920802762a7530ce67c241e67
parentreceive: disable bh before using stats seq lock (diff)
downloadWireGuard-502498c4fc05ae9eaaf3db6014f38d0033085859.tar.xz
WireGuard-502498c4fc05ae9eaaf3db6014f38d0033085859.zip
contrib: filter compat lines
-rwxr-xr-xcontrib/kernel-tree/filter-compat-defines.sh28
-rw-r--r--src/Makefile2
2 files changed, 29 insertions, 1 deletions
diff --git a/contrib/kernel-tree/filter-compat-defines.sh b/contrib/kernel-tree/filter-compat-defines.sh
new file mode 100755
index 00000000..9d2cc080
--- /dev/null
+++ b/contrib/kernel-tree/filter-compat-defines.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+silent=0
+level=0
+ifs=( )
+
+while IFS= read -r line; do
+ if [[ $line =~ ^[[:space:]]*(#if.*) ]]; then
+ ifs[level++]=0
+ if [[ ${BASH_REMATCH[1]} == "#ifndef COMPAT_CANNOT_"* ]]; then
+ ifs[level-1]=-1
+ continue
+ elif [[ ${BASH_REMATCH[1]} == "#ifdef COMPAT_CANNOT_"* ]]; then
+ ifs[level-1]=1
+ ((++silent))
+ continue
+ fi
+ elif [[ $line =~ ^[[:space:]]*#else && ${ifs[level-1]} -ne 0 ]]; then
+ ((ifs[level-1]*=-1))
+ ((silent+=ifs[level-1]))
+ continue
+ elif [[ $line =~ ^[[:space:]]*#endif ]]; then
+ ((--level))
+ [[ ${ifs[level]} -eq 1 ]] && ((--silent))
+ [[ ${ifs[level]} -ne 0 ]] && continue
+ fi
+ [[ $silent -eq 0 ]] && printf '%s\n' "$line"
+done < "$1"
diff --git a/src/Makefile b/src/Makefile
index 0a9f7342..f933eb19 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -68,7 +68,7 @@ coccicheck: clean
@$(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_WIREGUARD_DEBUG=y coccicheck MODE=report
cloc: clean
- cloc $(wildcard *.c) $(wildcard *.h)
+ @cloc --skip-uniqueness --by-file --extract-with="$$(readlink -f ../contrib/kernel-tree/filter-compat-defines.sh) >FILE< > \$$(basename >FILE<)" $(wildcard *.c) $(wildcard *.h)
-include tests/debug.mk