User Tools

Site Tools


coccicheck

This is an old revision of the document!


Go back –> Main Linux bot tests page

coccicheck

'coccicheck' is one of the targets of the Linux kernel, this page documents how you can use it, what it provides and how to help extend it. 'coccicheck' provides a series of semantic patches written in Semantic Patch Language (SmPL) and make use of the Coccinelle engine to interpret and complete these tests. These tests can help you vet for correctness and avoid certain bugs which have been able to be expressed semantically.

SmPL patches exist for these different types of categories, documented below.

Modes

There are three different modes you can use to use the semantic patches:

  • report - lets you generate a report - this is the 'default' mode if one is not specified
  • org - xxx
  • patch - lets you fix the issues found

You specify the mode want to operate

Run tests

By default all SmPL files will be used to run tests using the 'report' mode. To run all tests you can run:

make coccicheck MODE=report

Run specific tests

To only run a specific cocci test or a set of tests set the COCCI environment variable with the list of tests you want to run. For instance to only run the scripts/coccinelle/locks/double_lock.cocci you would use:

export COCCI=scripts/coccinelle/locks/double_lock.cocci
make coccicheck MODE=report

Types of tests

Below we document each type of test category which as been devised.

api

Help vet for correctness when using certain APIs. The following tests exist:

alloc_cast.cocci

scripts/coccinelle/api/alloc/alloc_cast.cocci

Remove casting the values returned by memory allocation functions like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc. This makes an effort to find cases of casting of values returned by kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc, kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes the casting as it is not required. The result in the patch case may need some reformatting.

kzalloc-simple.cocci

scripts/coccinelle/api/alloc/kzalloc-simple.cocci

Use kzalloc rather than kmalloc followed by memset with 0. This considers some simple cases that are common and easy to validate. Note in particular that there are no …s in the rule, so all of the matched code has to be contiguous.

free

Avoid freeing bugs

iterator

Help vet for correctness when using kernel iterators

locks

Vet for correct locking behaviour and avoid bugs

misc

Things not covered in any of the other categories.

null

Avoid null bugs

tests

Certain tests which are known to help with consistent kernel use.

coccicheck.1445443428.txt.gz · Last modified: 2015/10/21 16:03 by Luis R. Rodriguez