Closed cfehse closed 3 years ago
Wow, thanks a lot for not only implementing this, but addressing some of those warnings !!
@fenugrec
I implemented the Cmake integration for the Cppcheck analysis. This point are to be discussed from my point of view:
- Changed the minimum required Cmake version to
3.10
to be able to use the build-in cppcheck integration.
This can be solved differently by checking the cmake version before integration Cppcheck
- Added The Cppcheck target to the build process. The analysis will now run before any compilation of a source file.
This can be implemented differently for example by having a cmake configuration option to enable the checks.
- The analysis target is configured to fail if any warnings are found meaning that the software can only be build successfully if warning free.
This can also implemented differently to have only informative checks.
What are your options about this topics?
- Changed the minimum required Cmake version to
3.10
to be able to use the build-in cppcheck integration.
I think 3.10 is a reasonable requirement. Even ubuntu 18.04 has 3.10; if someone runs into problems because their distro doesn't have at least 3.10, we can do something different.
This can be implemented differently for example by having a cmake configuration option to enable the checks.
Hmm. On my system cppcheck is reasonably fast, but perhaps an option (default-enabled) would be nice, if it can be done without you ripping out all your additions and starting over? Otherwise I don't mind manually setting cppcheck to "NOTFOUND" to disable it.
- The analysis target is configured to fail if any warnings are found
Hehe, that's strong, but I think we have acceptable suppressions for this not to be too severe. I assume if cppcheck isn't found (or set to "NOTFOUND"), the analysis target is ignored ? (i.e. build can still succeed )
Hmm. On my system cppcheck is reasonably fast, but perhaps an option (default-enabled) would be nice, if it can be done without you ripping out all your additions and starting over? Otherwise I don't mind manually setting cppcheck to "NOTFOUND" to disable it.
This can be done but there is a caveat: Cmake treats the CMAKE_
I assume if cppcheck isn't found (or set to "NOTFOUND"), the analysis target is ignored ? (i.e. build can still succeed )
Yes. If cppcheck is not found during the initial generation of the build directory the analysis targets are not created. To create them after the initial configuration the build directory must be removed.
I added a corrected Embarcadero platform definition file to the cmake
directory. This is a bit out of place here but the platform file which comes with the C++ Builder Community edition does not work correctly with all compilers so I corrected the file.
I added a corrected Embarcadero platform definition file to the
cmake
directory.
Ok. Let me know when you're ready for this to be merged! (if you have a chance, can you check your whitespace - there seems to be one or two "missing newlines", and a bit of trailing space on a few lines)
Let me know when you're ready for this to be merged!
This PR is ready
(if you have a chance, can you check your whitespace - there seems to be one or two "missing newlines", and a bit of trailing space on a few lines)
Do you have an example in which file the formatting is off?
Do you have an example in which file the formatting is off?
It was minor EOL whitespace mostly. Fixed + rebased + merged , thanks !
My pleasure...
Scope
The scope of this PR is to integrate static code checks with Cppcheck. This integration will be done in two steps:
What has changed?
Source Files:
CMakeLists.txt
scantool/CMakeLists.txt
3.10
to be able to use the build-in cppcheck integration.cppcheck\win32.cppcheck
cppcheck\linux.cppcheck
cppcheck\run-cppckeck.bat
cppcheck
and split it into two platform specific configuration. This has the advantage that the sources will be tested more closely to the actual platform configured build process.unsignedLessThanZero
warning was added to the exclude list. This warning can be addressed in an later PR/commit to reduce the number of changed files for this PR.scantool/diag.h
scantool/diag_os.h
cconf.h.in
defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
) to define the Windows platform. This is done to unify the Windows detection in the header files and therefore only the_WIN32
define must be included in the Cppcheck project file.scantool/diag_l2_iso14230.c
nullPointerRedundantCheck
warning. This change should be reviewed.unreadVariable
warning by moving themsg.data = data;
to make the intention of the code clear to Cppcheck.scantool/diag_l2_saej1979.c
unreadVariable
warning by moving themsg.data = data;
to make the intention of the code clear to Cppcheck.scantool/scantool_cli.c
asctime()
with equivalent calls to thestrftime()
function to remove an obsolete warning.uninitializedVariable
warning caused by some defines in the code.scantool/diag_os_win.c
portability
warning issued for the Borland compiler environment because the formatter was signed and the parameter was unsigned (LONGLONG
).scantool/diag_cfg.c
uninitializedVariable
warning issued for the Borland bcc32x/bcc64 compiler environment caused by theassert
in thedefault
branch of theswitch
statement.Tested Environments:
All changes where tested using these environments:
Cppcheck:
Compiler/Build Environment:
Perhaps you like the changes and accept this merge request.
Thanks!
@fenugrec @nsajko