tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Using coccinelle for (quick?) syntax fixing
Dear all,
I occasionally see fixes committed for things like __arraycount() or
roundup() substitutions, done on a "per-file-per-interest" basis.
Would there be any use of fixing/cleaning (at least, kernel) code by
using devel/coccinelle [1] ?
I know, this sounds like janitor work, but using such tools makes it
easier to search and fix.
Let's take two simple examples to illustrate what I mean:
- one where I replace all sizeof(fooarray)/sizeof(foo) by its
__arraycount() equivalent, provided cdefs.h is included
http://www.netbsd.org/~jym/cocci/arraycount.diff
- another where I am trying to detect places where aprint_* calls could
be replaced by aprint_*_dev() (look for all aprint_*.diff files):
http://www.netbsd.org/~jym/cocci/
I perfectly understand the limitations of the approach. It is purely
cosmetic (at least in this case), risk of false positive (there are lots
for the aprint_* case, coccinelle is having a hard time with format
strings), and still needs proof-reading (and
even testing where non trivial spatchs are applied - before getting
caught by the regression test angels).
However, for parts where the syntax remains "generally" the same, it is
quite straight-forward. The cocci files are ~30 lines long, not
particularly hard to read, and are quite easier to get rolling than a
full sed/awk/vi/grep session. Took me a few hours to get a bit familiar
with it (let's say that the documentation is an on-going effort).
Opinions? Any interest in it? My intent is to put NetBSD specific
scripts on wiki.n.o, and provide links for more "generic" ones.
[1] http://wiki.netbsd.org/~jym/coccinelle/
--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost
Home |
Main Index |
Thread Index |
Old Index