Skip to contentSkip to conversation

fib_trie: avoid a redundant bit judgement in inflate

PATCH Superseded [email protected] 2 participants 2 messages Sep 29, 2013

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fib_trie: avoid a redundant bit judgement in inflate

From: "baker.zhang" <[email protected]>

Because 'node' is the i'st child of 'oldnode', thus, here 'i' equals
tkey_extract_bits(node->key, oldtnode->pos, oldtnode->bits)

we just get 1 more bit,
and need not care the detail value of this bits.

---
 net/ipv4/fib_trie.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
net/ipv4/fib_trie.c +3 -6
index 3df6d3e..45c74ba 100644
@@ -762,12 +762,9 @@ static struct tnode *inflate(struct trie *t, struct tnode *tn)
 
 		if (IS_LEAF(node) || ((struct tnode *) node)->pos >
 		   tn->pos + tn->bits - 1) {
-			if (tkey_extract_bits(node->key,
-					      oldtnode->pos + oldtnode->bits,
-					      1) == 0)
-				put_child(tn, 2*i, node);
-			else
-				put_child(tn, 2*i+1, node);
+			put_child(tn,
+				tkey_extract_bits(node->key, oldtnode->pos, oldtnode->bits + 1),
+				node);
 			continue;
 		}
 
Signature · 1 line
1.8.1.2
maintainer
#1 lore raw

Based upon how quickly you sent these two patches, the first of which wouldn't even compile, I have zero confidence that you actually booted and tested this patch at all.

I'm not applying this until you take the time to boot and test the change in some way, and say explicitly in your commit message how you tested it.