A list of some errors that Lint can check: Possible null pointers, this pointer is used after memory is released, assignment order problems, spelling errors, and so on. Generally, a C/C ++ compiler assumes that the program is correct, while Lint is the opposite. Therefore, it is better than the general check executed by the compiler. Lint can run through multiple files to perform error checking and code analysis. This is something the compiler cannot do. Popular Lint programs include: PC-lint is a commercial program provided by Gimpel Software that supports C/C ++; Splint (the original LCLint) it is a GNU Free Lint program, but only supports C and does not support C ++.
When running Lint, just like a normal compiler, you just need to add the makefile directly. You can control and calibrate the Lint output by configuring options and code annotations. For example, here is a function that returns a NULL pointer. Splint can be identified through the following comments/* @ null:
- /* @ Null @ */void * test (void)
- {
- // A function that returns NULL!
- Return NULL;
- }
This has two purposes: to prevent Splint from alerting the function that returns the Null pointer for this function; To ensure that Splint checks that the return pointer of this function is valid in any code that calls this function.
3) Flawfinder
Flawfinder is a security audit tool for c and c ++ programs written in Python to check potential security risks. It searches for the source code of the file to obtain potential security vulnerabilities. It supports detecting databases and generating reports in HTML format.