[20100808]
|
Janitorial code maintenance with coccinelle (Updated)
According to its
homepage,
coccinelle is
``a program matching and transformation engine which provides the language SmPL (Semantic Patch Language) for specifying desired matches and transformations in C code. Coccinelle was initially targeted towards performing collateral evolutions in Linux. Such evolutions comprise the changes that are needed in client code in response to evolutions in library APIs, and may include modifications such as renaming a function, adding a function argument whose value is somehow context-dependent, and reorganizing a data structure.''
Jean-Yves Migeon
has applied coccinelle to NetBSD, and suggested performing
two manual tasks, citing from
his email to tech-kern:
- replace all sizeof(fooarray)/sizeof(foo) calculations by its
__arraycount() macro equivalent, provided in cdefs.h
- detect places where aprint_* calls could
be replaced by aprint_*_dev() to save manual printing of the
device driver's name
Implementation of the coccinelle scripts,
resulting patched for NetBSD and more information
can be found
in Jean-Yves Migeon's posting,
his list of patches,
and
on his wiki page.
Update:
Jean-Yves' follow-up
includes further examples:
[Tags: coccinelle]
|