Skip to content

Commit

Permalink
[docs] Explain how to use Smatch and it's converter on the kernel
Browse files Browse the repository at this point in the history
- Smatch documentation in report converter explains the usage
  of smatch tool on kernel sources
- Smatch is accessible from the main readme file and supported
  code analyzer file
- Smatch and Coccinelle updated in usage
  • Loading branch information
jay24rajput committed Oct 13, 2020
1 parent 5a04a8e commit 7d83246
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ The following tools are supported:
| | [Cppcheck](/tools/report-converter/README.md#cppcheck) |
| | [Facebook Infer](/tools/report-converter/README.md#facebook-infer) |
| | [Coccinelle](/tools/report-converter/README.md#coccinelle) |
| | [Smatch](/tools/report-converter/README.md#smatch) |
| **Java** | [SpotBugs](/tools/report-converter/README.md#spotbugs) |
| | [Facebook Infer](/tools/report-converter/README.md#fbinfer) |
| **Python** | [Pylint](/tools/report-converter/README.md#pylint) |
Expand Down
1 change: 1 addition & 0 deletions docs/supported_code_analyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CodeChecker result directory which can be stored to a CodeChecker server.
| | [Cppcheck](/tools/report-converter/README.md#cppcheck) ||
| | [Facebook Infer](/tools/report-converter/README.md#fbinfer) ||
| | [Coccinelle](/tools/report-converter/README.md#coccinelle) ||
| | [Smatch](/tools/report-converter/README.md#smatch) ||
| **Java** | [FindBugs](http://findbugs.sourceforge.net/) ||
| | [SpotBugs](/tools/report-converter/README.md#spotbugs) ||
| | [Facebook Infer](/tools/report-converter/README.md#fbinfer) ||
Expand Down
27 changes: 27 additions & 0 deletions tools/report-converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ a CodeChecker server.
* [Pyflakes](#pyflakes)
* [Markdownlint](#markdownlint)
* [Coccinelle](#coccinelle)
* [Smatch](#smatch)
* [License](#license)

## Install guide
Expand Down Expand Up @@ -80,6 +81,7 @@ optional arguments:
Supported analyzers:
asan - AddressSanitizer, https://clang.llvm.org/docs/AddressSanitizer.html
clang-tidy - Clang Tidy, https://clang.llvm.org/extra/clang-tidy
coccinelle - Coccinelle, https://github.com/coccinelle/coccinelle
cppcheck - Cppcheck, http://cppcheck.sourceforge.net
eslint - ESLint, https://eslint.org/
fbinfer - Facebook Infer, https://fbinfer.com
Expand All @@ -88,6 +90,7 @@ Supported analyzers:
msan - MemorySanitizer, https://clang.llvm.org/docs/MemorySanitizer.html
pyflakes - Pyflakes, https://github.com/PyCQA/pyflakes
pylint - Pylint, https://www.pylint.org
smatch - smatch, https://repo.or.cz/w/smatch.git
spotbugs - spotbugs, https://spotbugs.github.io
tsan - ThreadSanitizer, https://clang.llvm.org/docs/ThreadSanitizer.html
tslint - TSLint, https://palantir.github.io/tslint
Expand Down Expand Up @@ -385,6 +388,7 @@ report-converter -t mdl -o ./codechecker_mdl_reports ./mdl_reports.out

# Store Markdownlint reports with CodeChecker.
CodeChecker store ./codechecker_mdl_reports -n mdl
```
## [Coccinelle](https://github.com/coccinelle/coccinelle)
[Coccinelle](https://github.com/coccinelle/coccinelle) allows programmers to easily
Expand All @@ -409,7 +413,30 @@ report-converter -t coccinelle -o ./codechecker_coccinelle_reports ./coccinelle_

# Store the Cocccinelle reports with CodeChecker.
CodeChecker store ./codechecker_coccinelle_reports -n coccinelle
```
## [Smatch](https://repo.or.cz/w/smatch.git)
[Smatch](https://repo.or.cz/w/smatch.git) is a static analysis tool for C that is used on the kernel.
The recommended way of running Smatch is to redirect the output to a file and
give this file to the report converter tool.
The following example shows you how to run Smatch on kernel sources
and store the results found by Smatch to the CodeChecker database.
```sh
# Change Directory to your project
cd path/to/linux/kernel/repository

# Run Smatch
# Note: The warnings will be stored by default into smatch_warns.txt after executing the following command
path/to/smatch/smatch_scripts/test_kernel.sh

# Use 'report-converter' to create a CodeChecker report directory from the
# analyzer result of Smatch
report-converter -t smatch -o ./codechecker_smatch_reports ./smatch_warns.txt

# Store the Smatch reports with CodeChecker.
CodeChecker store ./codechecker_smatch_reports -n smatch
```
## License
Expand Down

0 comments on commit 7d83246

Please sign in to comment.