Coccinelle (
French
French (french: français(e), link=no) may refer to:
* Something of, from, or related to France
** French language, which originated in France, and its various dialects and accents
** French people, a nation and ethnic group identified with Franc ...
for ''ladybug'') is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
utility for matching and
transforming the
source code
In computing, source code, or simply code, is any collection of code, with or without comment (computer programming), comments, written using a human-readable programming language, usually as plain text. The source code of a Computer program, p ...
of programs written in the
C programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming l ...
.
Utility
Coccinelle was initially used to aid the evolution of the
Linux kernel
The Linux kernel is a free and open-source, monolithic, modular, multitasking, Unix-like operating system kernel. It was originally authored in 1991 by Linus Torvalds for his i386-based PC, and it was soon adopted as the kernel for the GNU ...
, providing support for changes to library
application programming interfaces (APIs) such as renaming a
function, adding a function argument whose value is somehow context-dependent, and reorganizing a
data structure
In computer science, a data structure is a data organization, management, and storage format that is usually chosen for Efficiency, efficient Data access, access to data. More precisely, a data structure is a collection of data values, the rel ...
.
It can also be used to find defective programming patterns in code (i.e., pieces of code that are erroneous with high probability such as possible NULL pointer dereference) without transforming them. Then ''coccinelles role is close to that of
static analysis tools. Examples of such use are provided by the applications of the
herodotos' tool, which keeps track of warnings generated by ''coccinelle''.
Support for Coccinelle is provided by
IRILL. Funding for the development has been provided by the
Agence Nationale de la Recherche (France), the Danish Research Council for Technology and Production Sciences, and
INRIA
The National Institute for Research in Digital Science and Technology (Inria) () is a French national research institution focusing on computer science and applied mathematics.
It was created under the name ''Institut de recherche en informatiq ...
.
The source code of Coccinelle is licensed under the terms of version 2 of the
GNU General Public License
The GNU General Public License (GNU GPL or simply GPL) is a series of widely used free software licenses that guarantee end user
In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ulti ...
(GPL).
Semantic Patch Language
The source code to be matched or replaced is specified using a "semantic patch" syntax based on the
patch
Patch or Patches may refer to:
Arts, entertainment and media
* Patch Johnson, a fictional character from ''Days of Our Lives''
* Patch (''My Little Pony''), a toy
* "Patches" (Dickey Lee song), 1962
* "Patches" (Chairmen of the Board song ...
syntax. The Semantic Patch Language (SmPL) pattern resembles a
unified diff with C-like declarations.
Example
@@
expression lock, flags;
expression urb;
@@
spin_lock_irqsave(lock, flags);
<...
- usb_submit_urb(urb)
+ usb_submit_urb(urb, GFP_ATOMIC)
...>
spin_unlock_irqrestore(lock, flags);
@@
expression urb;
@@
- usb_submit_urb(urb)
+ usb_submit_urb(urb, GFP_KERNEL)
References
External links
* {{GitHub, coccinelle/coccinelle, Source code repository
Official latest stable downloadCoccinellery: Semantic Patch Gallery
Code refactoring
Static program analysis tools
Software using the GPL license