lkml.org 
[lkml]   [2012]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Subject[PATCH 0/6] ensure a consistent return value in error case
    Date
    Typically, the return value desired for the failure of a function with an
    integer return value is a negative integer. In these cases, the return
    value is sometimes a negative integer and sometimes 0, due to a subsequent
    initialization of the return variable within the loop.

    The semantic match that finds this problem is:
    (http://coccinelle.lip6.fr/)

    //<smpl>
    @r exists@
    identifier ret;
    position p;
    constant C;
    expression e1,e2,e3,e4;
    @@

    ret = -C
    ... when != ret = e1
    when != ret += e1
    when any
    if@p (...)
    {
    ... when != ret = e2
    when != ret + e2
    return ret;
    }
    ... when any
    if (\(ret != 0\|ret < 0\|ret > 0\) || ...)
    {
    ...
    return ...;
    }
    ... when != ret = e3
    when != ret += e3
    when any
    if@p (...)
    {
    ... when != ret = e4
    when != ret += e4
    return ret;
    }

    @@
    identifier r.ret;
    position r.p;
    statement S;
    @@

    (
    if@p (<+...ret...+>) S
    |
    *if@p (...) S
    )
    //</smpl>



    \
     
     \ /
      Last update: 2012-07-14 19:22    [W:0.040 / U:0.020 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site