Merge pull request #120 from linD026/master

CI: Introduce GCC static analysis
This commit is contained in:
Jim Huang 2021-10-08 20:58:52 +08:00 committed by GitHub
commit 1cb35ac976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 2 deletions

View File

@ -60,6 +60,28 @@ function do_sparse()
make -C examples clean
}
function do_gcc()
{
local GCC=$(which gcc-10)
if [ $? -ne 0 ]; then
echo "[!] gcc-10 is not installed. Failed to run static analysis with GCC." >&2
exit 1
fi
make -C examples CONFIG_STATUS_CHECK_GCC=y STATUS_CHECK_GCC=$GCC 2> gcc.log
local WARNING_COUNT=$(cat gcc.log | egrep -c " warning:" )
local ERROR_COUNT=$(cat gcc.log | egrep -c " error:" )
local COUNT=`expr $WARNING_COUNT + $ERROR_COUNT`
if [ $COUNT -gt 0 ]; then
echo "gcc failed: $WARNING_COUNT warning(s), $ERROR_COUNT error(s)"
cat gcc.log
exit 1
fi
make -C examples CONFIG_STATUS_CHECK_GCC=y STATUS_CHECK_GCC=$GCC clean
}
do_cppcheck
do_sparse
do_gcc
exit 0

View File

@ -18,6 +18,7 @@ jobs:
run: |
sudo apt-get install -q -y clang-format-11
sudo apt-get install -q -y cppcheck
sudo apt-get install -q -y gcc-10
.ci/check-format.sh
.ci/static-analysis.sh
.ci/build-n-run.sh

View File

@ -32,11 +32,16 @@ obj-m += ioctl.o
PWD := $(CURDIR)
ifeq ($(CONFIG_STATUS_CHECK_GCC),y)
CC=$(STATUS_CHECK_GCC)
ccflags-y += -fanalyzer
endif
all:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
$(MAKE) -C /lib/modules/$(shell uname -r)/build CC=$(CC) M=$(PWD) modules
clean:
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
$(MAKE) -C /lib/modules/$(shell uname -r)/build CC=$(CC) M=$(PWD) clean
$(RM) other/cat_noblock *.plist
indent: