This is a gallery of semantic patches for use with Coccinelle . They are extracted automatically from a collection of semantic patches that have been used to create patches for the Linux Kernel and other software. The descriptions are derived from the commit messages contained in those patches. There is no guarantee that the descriptions are correct or understandable, and no guarantee that the semantic patches are correct, complete, or work with the latest version of Coccinelle. Comments and corrections may be sent to the Coccinelle mailing list: cocci@systeme.lip6.fr

To propose new semantic patches to be added to the gallery, please make a pull request via Github to Coccinellery repository. When adding new semantic patches, please create a folder for you under the CONTRIB directory. Detailed instructions on the README file of the CONTRIB directory.

The semantic patches are licensed under the permissive ISC license. More info at LICENSE file or http://www.isc.org/software/license.

All files are stored in a git repository that can be accessed here. You can also download all files in a zip archive here.

Target: Generic

Target: Linux

Target: Firehose

CONTRIB/firehose/arref/arref.cocci - Adjust array index

Convert array index from the loop bound to the loop index.

The pattern !E && !E->fld is nonsensical. The patch below updates this according to the assumption that && should be ||. But perhaps another solution was intended.

Typically, the return value desired for the failure of a function with an integer return value is a negative integer. In these cases, the return value is sometimes a negative integer and sometimes 0, due to a subsequent initialization of the return variable within the loop.

The use of & to obtain a conjunction that evaluates both of its arguments seems unnecessarily tricky.

The double assignment is meant to be a bit-or to combine two values.

Test the value that was just allocated rather than the previously tested one.

The definition of uml_netdev_ops has initializations of a local function and eth_mac_addr for its ndo_set_mac_address field. This change uses only the local function.

The current code tests the gpio_vid0 field twice. Test the gpio_vid1 fields in place of the second gpio_vid0 test.

Continue is not needed at the bottom of a loop.

Detect a semicolon after if(...) that is preventing the error check to work correctly. Removing this semicolon will change the code behavior, but this is intended.

the address of a variable or field is non-zero is likely always to bo non-zero

The size argument to kcalloc should be the size of desired structure, not the pointer to it.

Useless goto and return