lib/classifier: Clarify trie_lookup_value().
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 13 Jun 2014 21:52:59 +0000 (14:52 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Fri, 13 Jun 2014 21:55:04 +0000 (14:55 -0700)
trie_lookup_value() is easier to read with the local variable 'plen'
renamed as 'ofs'.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/classifier.c

index a0ba6ab..140d9e3 100644 (file)
@@ -2134,26 +2134,26 @@ static unsigned int
 trie_lookup_value(const struct trie_node *node, const ovs_be32 value[],
                   unsigned int *checkbits)
 {
-    unsigned int plen = 0, match_len = 0;
+    unsigned int ofs = 0, match_len = 0;
     const struct trie_node *prev = NULL;
 
-    for (; node; prev = node, node = trie_next_node(node, value, plen)) {
+    for (; node; prev = node, node = trie_next_node(node, value, ofs)) {
         unsigned int eqbits;
         /* Check if this edge can be followed. */
-        eqbits = prefix_equal_bits(node->prefix, node->nbits, value, plen);
-        plen += eqbits;
+        eqbits = prefix_equal_bits(node->prefix, node->nbits, value, ofs);
+        ofs += eqbits;
         if (eqbits < node->nbits) { /* Mismatch, nothing more to be found. */
-            /* Bit at offset 'plen' differed. */
-            *checkbits = plen + 1; /* Includes the first mismatching bit. */
+            /* Bit at offset 'ofs' differed. */
+            *checkbits = ofs + 1; /* Includes the first mismatching bit. */
             return match_len;
         }
         /* Full match, check if rules exist at this prefix length. */
         if (node->n_rules > 0) {
-            match_len = plen;
+            match_len = ofs;
         }
     }
     /* Dead end, exclude the other branch if it exists. */
-    *checkbits = !prev || trie_is_leaf(prev) ? plen : plen + 1;
+    *checkbits = !prev || trie_is_leaf(prev) ? ofs : ofs + 1;
     return match_len;
 }