Skip to contentSkip to conversation

neighbour: Convert if statment in the function, neigh_add_timer to a WARN_ON

PATCH YOSHIFUJI Hideaki/吉藤英明 2 participants 2 messages Jun 2, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 16 lines · Nicholas Krause

This converts the if statement for dumping the stack into a WARN_ON in order to make this function's debugging check simpler and have a cleaner output when this condition occurs inside this function for when bugs related to adding a duplicate neighbour table timer arise.

---
 net/core/neighbour.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/core/neighbour.c +0 -0
index 3de6542..0bf71da 100644

net/core/neighbour.c static int neigh_forced_gc(struct neigh_table *tbl) · line 169

Quoted 10 lines
net/core/neighbour.c +1 -5
@@ -165,11 +165,7 @@ static int neigh_forced_gc(struct neigh_table *tbl)
 static void neigh_add_timer(struct neighbour *n, unsigned long when)
 {
 	neigh_hold(n);
-	if (unlikely(mod_timer(&n->timer, when))) {
-		printk("NEIGH: BUG, double timer add, state is %x\n",
-		       n->nud_state);
-		dump_stack();
-	}
+	WARN_ON(unlikely(mod_timer(&n->timer, when)));
 }

NACK, please do not use WARN_ON for things with side effects.

--yoshfuji

#2 lore raw
Quoted 21 lines · YOSHIFUJI Hideaki/吉藤英明
Quoted 20 lines · Nicholas Krause

This converts the if statement for dumping the stack into a WARN_ON in order to make this function's debugging check simpler and have a cleaner output when this condition occurs inside this function for when bugs related to adding a duplicate neighbour table timer arise.

---
 net/core/neighbour.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
net/core/neighbour.c +0 -1
index 3de6542..0bf71da 100644
@@ -165,11 +165,7 @@ static int neigh_forced_gc(struct neigh_table *tbl)
 static void neigh_add_timer(struct neighbour *n, unsigned long when)
 {
      neigh_hold(n);
-     if (unlikely(mod_timer(&n->timer, when))) {
Quoted 8 lines

net/core/neighbour.c static int neigh_forced_gc(struct neigh_table *tbl) · line 169

Quoted 6 lines
net/core/neighbour.c +1 -4
-             printk("NEIGH: BUG, double timer add, state is %x\n",
-                    n->nud_state);
-             dump_stack();
-     }
+     WARN_ON(unlikely(mod_timer(&n->timer, when)));
 }

NACK, please do not use WARN_ON for things with side effects.

Just:

int ret = mod_timer(...);
WARN_ON(ret);
...