mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
Remove cppcheck from CI, add to tools/
We don't enforce cppcheck through the CI, although it's there since years. It runs on Ubuntu 18/20, so it's old. For folks, it's likely not discoverable on how to run it locally. Let's make a fresh start. This removes cppcheck from all CI-related code. Instead, it adds it under tools/cppcheck/, including documentation on how to run it locally, bare-matel or in docker. Signed-off-by: Robert Schmidt <robert.schmidt@openairinterface.org>
This commit is contained in:
28
tools/cppcheck/README.md
Normal file
28
tools/cppcheck/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- SPDX-License-Identifier: CC-BY-4.0 -->
|
||||
|
||||
# Static code analysis
|
||||
|
||||
How to run static code analysis tool(s).
|
||||
|
||||
[[_TOC_]]
|
||||
|
||||
## cppcheck Overview
|
||||
|
||||
This can run a (dockerized) cppcheck static code analysis. The docker-compose
|
||||
file represents the status as run as in the CI until it's removal (because it
|
||||
was not enforced). It is now here so that people could use it to find bugs (and
|
||||
use the tool more easily).
|
||||
|
||||
## cppcheck Usage
|
||||
|
||||
From the openairinterface5g root, simply run
|
||||
|
||||
./tools/cppcheck/run-cppcheck.sh
|
||||
|
||||
This will run cppcheck with options listed in this file, assuming you have it
|
||||
installed. Alternatively, you can run the CI version as of Ubuntu 20 with
|
||||
|
||||
cd tools/cppcheck && docker compose up --no-log-prefix
|
||||
|
||||
You can upgrade to a newer version by modifying the `FROM` line in the
|
||||
docker-compose file.
|
||||
14
tools/cppcheck/docker-compose.yaml
Normal file
14
tools/cppcheck/docker-compose.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
services:
|
||||
cppcheck:
|
||||
image: cppcheck
|
||||
build:
|
||||
dockerfile_inline: |
|
||||
FROM ubuntu:focal
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y cppcheck
|
||||
volumes:
|
||||
- ../../:/code/
|
||||
command:
|
||||
bash -c "cd /code/ && ./tools/cppcheck/run-cppcheck.sh"
|
||||
|
||||
11
tools/cppcheck/run-cppcheck.sh
Executable file
11
tools/cppcheck/run-cppcheck.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
cppcheck --enable=warning --force \
|
||||
--inline-suppr \
|
||||
--quiet \
|
||||
-i openair1/PHY/CODING/nrLDPC_decoder/nrLDPC_decoder.c \
|
||||
--suppressions-list=tools/cppcheck/suppressions.list \
|
||||
-I common/utils \
|
||||
-I openair3/NAS/COMMON/UTIL \
|
||||
-j`nproc` .
|
||||
94
tools/cppcheck/suppressions.list
Normal file
94
tools/cppcheck/suppressions.list
Normal file
@@ -0,0 +1,94 @@
|
||||
// *INDENT-OFF* cppcheck doesn't like "astyling" this file!!!!
|
||||
// SPDX-License-Identifier: LicenseRef-CSSL-1.0
|
||||
//*****************************************************************************
|
||||
//*****************************************************************************
|
||||
// section for "valid" memory leaks: the related functions are allocators and
|
||||
// the caller is responsible of freeing the memory. cppcheck has a mechanism
|
||||
// to check more accuretaly this, by defining callers responsible of freeing
|
||||
// but tools like valgring might be more suitable
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// suppress error about keysP memory leak, free must be done by calling func
|
||||
memleak:common/utils/hashtable/obj_hashtable.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// suppress error about keys memory leak, free must be done by calling func
|
||||
memleak:openair2/UTIL/OMG/omg_hashtable.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// suppress error about data memory leak. This is the buffer where
|
||||
// _emm_as_encode function creates the encoded buffer
|
||||
//
|
||||
memleak:openair3/NAS/UE/EMM/SAP/emm_as.c
|
||||
memleak:openair1/PHY/INIT/nr_init_ue.c
|
||||
//-----------------------------------------------------------------------------
|
||||
//*****************************************************************************
|
||||
// section for files not used in oai exec's included in CI.
|
||||
// Possibly candidates for removal otherwise should be documented and updated
|
||||
// for project rules enforcement
|
||||
// ----------------------------------------------------------------------------
|
||||
// likely sources for test programs, maintained?
|
||||
invalidPrintfArgType_sint:openair1/PHY/CODING/TESTBENCH/ltetest.c
|
||||
memleak:openair1/PHY/CODING/TESTBENCH/ltetest.c
|
||||
invalidPrintfArgType_sint:openair1/PHY/CODING/TESTBENCH/pdcch_test.c
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// is itti analyzer deprecated
|
||||
nullPointer:common/utils/itti_analyzer/itti_analyzer.c
|
||||
nullPointerRedundantCheck:common/utils/itti_analyzer/libbuffers/buffers.c
|
||||
doubleFree:common/utils/itti_analyzer/libbuffers/socket.c
|
||||
memleak:common/utils/itti_analyzer/libbuffers/socket.c
|
||||
memleak:common/utils/itti_analyzer/libparser/array_type.c
|
||||
memleak:common/utils/itti_analyzer/libui/ui_callbacks.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// obviously never even compiled!!!
|
||||
syntaxError:openair1/SIMULATION/LTE_PHY/dlsim_tm4.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// omg, otg commented out in cmakelist to be cleaned up definitely?
|
||||
arrayIndexOutOfBounds:openair2/UTIL/OMG/omg.c
|
||||
uninitvar:openair2/UTIL/OTG/otg_rx_socket.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// cppcheck is not able to understand that buf is initialized at the first
|
||||
// iteration of the loop.
|
||||
nullPointer:common/utils/T/local_tracer.c:243
|
||||
//-----------------------------------------------------------------------------
|
||||
// once again cppcheck does not understand that fds is initialized in the
|
||||
// first iteration of the loop
|
||||
nullPointer:common/utils/T/tracer/multi.c:264
|
||||
nullPointer:common/utils/T/tracer/multi.c:265
|
||||
//-----------------------------------------------------------------------------
|
||||
// this file is used for testing the RLC V2 implementation, this error is
|
||||
// not a problem, the programmer has to know what she does when writing
|
||||
// the tests
|
||||
arrayIndexOutOfBounds:openair2/LAYER2/rlc_v2/tests/test.c:401
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// this file is used for testing the NR RLC implementation, this error is
|
||||
// not a problem, the programmer has to know what she does when writing
|
||||
// the tests
|
||||
arrayIndexOutOfBounds:openair2/LAYER2/nr_rlc/tests/test.c:451
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// cppcheck does not understand the different lengths of arrays
|
||||
arrayIndexOutOfBounds:openair1/SIMULATION/TOOLS/random_channel.c:705
|
||||
arrayIndexOutOfBounds:openair1/SIMULATION/TOOLS/random_channel.c:706
|
||||
//*****************************************************************************
|
||||
//
|
||||
// True problems we don't know how to fix, Suppression is commented out,
|
||||
// as these kind of problem need either to be fixed or can be suppressed
|
||||
// when fully uderstood
|
||||
//-----------------------------------------------------------------------------
|
||||
// the function [nv]fapi_pnf_p7_config_create should return
|
||||
// _this. _this points to a structure and a dynamically allocated field is
|
||||
// returned. cppcheck suspects _this will never be released, so do i
|
||||
// memleak:nfapi/open-nFAPI/pnf/src/pnf_p7_interface.c
|
||||
// memleak:nfapi/open-nFAPI/vnf/src/vnf_p7_interface.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// may be security_data->kenb.value is released from calling functions. But even
|
||||
// when, for test, freeing it before returning from emm_proc_security_mode_command
|
||||
// which does the allocation, cppcheck complains. So something might be wrong...
|
||||
// memleak:openair3/NAS/UE/EMM/SecurityModeControl.c
|
||||
//-----------------------------------------------------------------------------
|
||||
// when used, nobody but the original developer can guess if sn_data_cnf is set or not
|
||||
// cppcheck found that in some cases it is not, code needs cleanup before fixing that...
|
||||
// uninitvar:openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c
|
||||
//*****************************************************************************
|
||||
// *INDENT-ON*
|
||||
Reference in New Issue
Block a user