Skip to content

Commit

Permalink
drivers/char/mmtimer.c: eliminate useless code
Browse files Browse the repository at this point in the history
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 cbacdd9 "SGI Altix mmtimer:
  allow larger number of timers per node" in 2.6.26.

Signed-off-by: Julia Lawall <julia@diku.dk>
Cc: Stefan Richter <stefanr@s5r6.in-berlin.de>
Cc: Dimitri Sivanich <sivanich@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Julia Lawall authored and Linus Torvalds committed Mar 12, 2010
1 parent 582ef52 commit 0fbcae2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/mmtimer.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ static void mmtimer_tasklet(unsigned long data)
{
int nodeid = data;
struct mmtimer_node *mn = &timers[nodeid];
struct mmtimer *x = rb_entry(mn->next, struct mmtimer, list);
struct mmtimer *x;
struct k_itimer *t;
unsigned long flags;

Expand Down

0 comments on commit 0fbcae2

Please sign in to comment.