Thanks. I tried this too, but I wasn't sure about the results. Thevery interesting! Honestly I hadn't thought much further than what you see in my semantic patch. I'd noticed piece of code in the iwlegacy driver and wondered what'd happen if I taught myself a little bit about cocci :)
question is why stop here.
For example, there are IS_ERR calls that oneThere seem to be many variations on the theme to consider... though hopefully the compiler optimizes most of these out... For example, in sound/soc/codecs/wm8940.c, Jonathan Cameron pointed some code out to me that looks like this:
could consider as well. Or ret< 0. Or why not just:
@@
expression ret;
@@
- if (...) return ret;
return ret;
Although there might be function calls that one doesn't want to touch, so:
@@
identifier f != IS_ERR;
expression ret;
statement S;
@@
(
if (<+...f(...)...+>) S
|
- if (...) return ret;
return ret;
)
julia