• J
    drivers/net/ax88796.c: Return error code in failure · 13eea192
    Julia Lawall 提交于
    In this code, 0 is returned on failure, even though other
    failures return -ENOMEM or other similar values.
    
    A simplified version of the semantic match that finds this problem is as
    follows: (http://coccinelle.lip6.fr/)
    
    // <smpl>
    @a@
    identifier alloc;
    identifier ret;
    constant C;
    expression x;
    @@
    
    x = alloc(...);
    if (x == NULL) { <+... \(ret = -C; \| return -C; \) ...+> }
    
    @@
    identifier f, a.alloc;
    expression ret;
    expression x,e1,e2,e3;
    @@
    
    ret = 0
    ... when != ret = e1
    *x = alloc(...)
    ... when != ret = e2
    if (x == NULL) { ... when != ret = e3
      return ret;
    }
    // </smpl>
    Signed-off-by: NJulia Lawall <julia@diku.dk>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    13eea192
ax88796.c 24.8 KB