From 1b2764421c940ee03d536b2ec9506c30d280b21d Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 8 May 2017 12:46:11 -0700 Subject: [PATCH] build: Automatically detect use of POSIX includes Scan the source for POSIX includes outside of the allowed locations in check_format.sh. This only tests for POSIX headers - not Linux Standards Base. Also, fix one bug that was caught by this addition. Change-Id: Ib0ca93fe6ac552dc49d95b27b4803e40282027e8 Signed-off-by: Ben Walker --- include/spdk/stdinc.h | 1 + lib/net/interface.c | 2 - scripts/check_format.sh | 11 ++++++ scripts/posix.txt | 82 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 scripts/posix.txt diff --git a/include/spdk/stdinc.h b/include/spdk/stdinc.h index 9f473606b..586a94f56 100644 --- a/include/spdk/stdinc.h +++ b/include/spdk/stdinc.h @@ -72,6 +72,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/lib/net/interface.c b/lib/net/interface.c index e7125607c..de9cb4f43 100644 --- a/lib/net/interface.c +++ b/lib/net/interface.c @@ -42,8 +42,6 @@ #include #include -#include - static TAILQ_HEAD(, spdk_interface) g_interface_head; diff --git a/scripts/check_format.sh b/scripts/check_format.sh index a4dd1fdad..ec128f45b 100755 --- a/scripts/check_format.sh +++ b/scripts/check_format.sh @@ -62,6 +62,17 @@ else fi rm -f eofnl.log +echo -n "Checking for POSIX includes..." +git grep -I -i -f scripts/posix.txt -- './*' ':!include/spdk/stdinc.h' ':!lib/vhost/rte_vhost/**' ':!scripts/posix.txt' > scripts/posix.log || true +if [ -s scripts/posix.log ]; then + echo "POSIX includes detected. Please include spdk/stdinc.h instead." + cat scripts/posix.log + rc=1 +else + echo " OK" +fi +rm -f scripts/posix.log + if hash pep8; then echo -n "Checking Python style..." diff --git a/scripts/posix.txt b/scripts/posix.txt new file mode 100644 index 000000000..2d07f23df --- /dev/null +++ b/scripts/posix.txt @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +