• Julia Lawall's avatar
    drivers/char/mmtimer.c: eliminate useless code · 0fbcae22
    Julia Lawall authored
    The variable x is initialized twice to the same (side effect-free)
    expression.  Drop one initialization.
    
    A simplified version of the semantic match that finds this problem is:
    (http://coccinelle.lip6.fr/)
    
    // <smpl>
    @forall@
    idexpression *x;
    identifier f!=ERR_PTR;
    @@
    
    x = f(...)
    ... when != x
    (
    x = f(...,<+...x...+>,...)
    |
    * x = f(...)
    )
    // </smpl>
    
    Stefan observed:
    
      The next x = rb_entry(mn->next, struct mmtimer, list); is preceded by a
      test whether mn->next is NULL.
    
      Unless that test is redundant too, your patch fixes a potential NULL
      pointer dereference, introduced by commit cbacdd95 "SGI Altix mmtimer:
      allow larger number of timers per node" in 2.6.26.
    Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
    Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
    Cc: Dimitri Sivanich <sivanich@sgi.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    0fbcae22
mmtimer.c 20.3 KB