Another case where just returning a negative value gets rid of
call by reference. In this case the return value for checkleaf is
now:
        -1      no match
        0..32   prefix length

Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>


--- a/net/ipv4/fib_trie.c       2008-01-14 18:02:18.000000000 -0800
+++ b/net/ipv4/fib_trie.c       2008-01-14 18:37:51.000000000 -0800
@@ -1277,36 +1277,36 @@ err:
 
 
 /* should be called with rcu_read_lock */
-static inline int check_leaf(struct trie *t, struct leaf *l,
-                            t_key key, int *plen, const struct flowi *flp,
-                            struct fib_result *res)
+static int check_leaf(struct trie *t, struct leaf *l,
+                     t_key key,  const struct flowi *flp,
+                     struct fib_result *res)
 {
-       int err, i;
-       __be32 mask;
        struct leaf_info *li;
        struct hlist_head *hhead = &l->list;
        struct hlist_node *node;
 
        hlist_for_each_entry_rcu(li, node, hhead, hlist) {
-               i = li->plen;
-               mask = inet_make_mask(i);
+               int err;
+               int plen = li->plen;
+               __be32 mask = inet_make_mask(plen);
+
                if (l->key != (key & ntohl(mask)))
                        continue;
 
                err = fib_semantic_match(&li->falh, flp, res,
-                                        htonl(l->key), mask, i);
-               if (err <= 0) {
-                       *plen = i;
+                                        htonl(l->key), mask, plen);
+
 #ifdef CONFIG_IP_FIB_TRIE_STATS
+               if (err <= 0)
                        t->stats.semantic_match_passed++;
+               else
+                       t->stats.semantic_match_miss++;
 #endif
-                       return err;
-               }
-#ifdef CONFIG_IP_FIB_TRIE_STATS
-               t->stats.semantic_match_miss++;
-#endif
+               if (err <= 0)
+                       return plen;
        }
-       return 1;
+
+       return -1;
 }
 
 static int
@@ -1337,11 +1337,13 @@ fn_trie_lookup(struct fib_table *tb, con
 
        /* Just a leaf? */
        if (IS_LEAF(n)) {
-               ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, res);
-               if (ret <= 0)
-                       goto found;
-               goto failed;
+               plen = check_leaf(t, (struct leaf *)n, key, flp, res);
+               if (plen < 0)
+                       goto failed;
+               ret = 0;
+               goto found;
        }
+
        pn = (struct tnode *) n;
        chopped_off = 0;
 
@@ -1363,11 +1365,12 @@ fn_trie_lookup(struct fib_table *tb, con
                }
 
                if (IS_LEAF(n)) {
-                       ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, 
res);
-                       if (ret <= 0)
-                               goto found;
-                       else
+                       plen = check_leaf(t, (struct leaf *)n, key, flp, res);
+                       if (plen < 0)
                                goto backtrace;
+
+                       ret = 0;
+                       goto found;
                }
 
                cn = (struct tnode *)n;
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to