lkml.org 
[lkml]   [2011]   [Jun]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] coccinelle: if(ret)return ret; return ret; semantic patch
    Hi Julia,

    On 06/05/2011 11:55 PM, Julia Lawall wrote:
    > Thanks. I tried this too, but I wasn't sure about the results. The
    > question is why stop here.
    very 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 :)
    > For example, there are IS_ERR calls that one
    > 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
    >
    >
    >
    There 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:

    if (ret)
    goto error_ret;

    error_ret:
    return ret;




    As an aside, I added a feature to the script for myself so that I can
    for example write 'make coccicheck M=drivers/net/wireless/' for example
    to focus in on that directory and just run the checks there... I can
    submit a patch for this... though I was wondering if there is already a
    way to do this and I just missed it. The thought was to make it work the
    same way you'd build a module.


    Greg



    \
     
     \ /
      Last update: 2011-06-07 17:51    [W:0.024 / U:65.008 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site