Remix.run Logo
Coccinelle: The Linux kernel's source-to-source transformation tool(github.com)
24 points by anon111332142 4 hours ago | 6 comments
twic 16 minutes ago | parent | next [-]

According to https://coccinelle.gitlabpages.inria.fr/website/ce.html :

> Nevertheless, detecting the holding of locks requires a careful and occasionally interprocedural analysis of the source code, and the other conditions, such as "in a completion handler", are not formally defined and require study of multiple files.

> Due to the complexity of the conditions governing the choice of new argument for usb_submit_urb, 71 of the 158 calls to this function were initially transformed incorrectly to use GFP_KERNEL instead of GFP_ATOMIC.

Okay, but how does Coccinelle help? Is it able to do this careful and not formally defined analysis? Or does it automate the undifferentiated heavy lifting and so make it easier for humans to do it?

eqvinox 42 minutes ago | parent | prev | next [-]

It's a bit of a disservice to call it "The Linux kernel's"; it's its own project that just happens to be used on the Linux kernel quite a bit. It doesn't originate there or belong to the kernel or anything like that.

twic 16 minutes ago | parent | prev | next [-]

See also OpenRewrite:

https://github.com/openrewrite/rewrite

And i assume any large organisation running a monorepo has some vaguely equivalent tooling for making mass changes. Have any of them published about that?

conartist6 2 hours ago | parent | prev [-]

I forgot about Coccinelle.

I think semantic patching is an idea whose time has come though. I'm making a more modern set of tools for source-to-source transformation that will work with any desired languages as the input and output.

fweimer an hour ago | parent [-]

Those tools exist, but you have to pay by the token. I'm not sure if they scale financially to large code bases such as the Linux kernel. They are far more accessible than Coccinelle or Perl, though.

eqvinox 41 minutes ago | parent [-]

Honestly, I rather use Coccinelle, where I understand exactly what it does, when it does it and why it does it…