mirror of
https://github.com/sysprog21/lkmpg.git
synced 2024-11-25 17:56:36 +08:00
CI: introduce GCC static analysis
Since GCC version 10, there has been a new option -fanalyzer for
static analysis. It can make the CI pipeline more comprehensive.
Also, the static analysis updates in GCC 11, but we cannot install
the GCC 11 in ubuntu 20.04 straightforwardly right now, which is
the GitHub workflow environment (see status-check.yaml).
For this reason, we stay at the GCC 10.
Close #117
Reference
- https://gcc.gnu.org/onlinedocs/gcc-10.1.0/gcc/Static-Analyzer-Options.html
- https://developers.redhat.com/blog/2020/03/26/static-analysis-in-gcc-10
- https://lwn.net/Articles/870290/
- https://developers.redhat.com/blog/2021/01/28/static-analysis-updates-in-gcc-11
- 7d73c3e9c5
This commit is contained in:
parent
b0bbe0121f
commit
d6e1044aa7
|
@ -60,6 +60,28 @@ function do_sparse()
|
||||||
make -C examples clean
|
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_cppcheck
|
||||||
do_sparse
|
do_sparse
|
||||||
|
do_gcc
|
||||||
exit 0
|
exit 0
|
||||||
|
|
1
.github/workflows/status-check.yaml
vendored
1
.github/workflows/status-check.yaml
vendored
|
@ -18,6 +18,7 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get install -q -y clang-format-11
|
sudo apt-get install -q -y clang-format-11
|
||||||
sudo apt-get install -q -y cppcheck
|
sudo apt-get install -q -y cppcheck
|
||||||
|
sudo apt-get install -q -y gcc-10
|
||||||
.ci/check-format.sh
|
.ci/check-format.sh
|
||||||
.ci/static-analysis.sh
|
.ci/static-analysis.sh
|
||||||
.ci/build-n-run.sh
|
.ci/build-n-run.sh
|
||||||
|
|
|
@ -32,11 +32,16 @@ obj-m += ioctl.o
|
||||||
|
|
||||||
PWD := $(CURDIR)
|
PWD := $(CURDIR)
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_STATUS_CHECK_GCC),y)
|
||||||
|
CC=$(STATUS_CHECK_GCC)
|
||||||
|
ccflags-y += -fanalyzer
|
||||||
|
endif
|
||||||
|
|
||||||
all:
|
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:
|
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
|
$(RM) other/cat_noblock *.plist
|
||||||
|
|
||||||
indent:
|
indent:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user