Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=fea86ad8123df0d49188cbc1dd2f48da6ae49d65
Commit:     fea86ad8123df0d49188cbc1dd2f48da6ae49d65
Parent:     187b5188a78694fa6608fa1252d5197a7b3ab076
Author:     Stephen Hemminger <[EMAIL PROTECTED]>
AuthorDate: Sat Jan 12 20:57:07 2008 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:01:54 2008 -0800

    [IPV4] fib_trie: fib_insert_node cleanup
    
    The only error from fib_insert_node is if memory allocation fails, so
    instead of passing by reference, just use the convention of returning
    NULL.
    
    Signed-off-by: Stephen Hemminger <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/ipv4/fib_trie.c |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f5c046b..e047de6 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -980,8 +980,7 @@ static struct node *trie_rebalance(struct trie *t, struct 
tnode *tn)
 
 /* only used from updater-side */
 
-static  struct list_head *
-fib_insert_node(struct trie *t, int *err, u32 key, int plen)
+static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
 {
        int pos, newpos;
        struct tnode *tp = NULL, *tn = NULL;
@@ -1043,10 +1042,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int 
plen)
 
                li = leaf_info_new(plen);
 
-               if (!li) {
-                       *err = -ENOMEM;
-                       goto done;
-               }
+               if (!li)
+                       return NULL;
 
                fa_head = &li->falh;
                insert_leaf_info(&l->list, li);
@@ -1055,18 +1052,15 @@ fib_insert_node(struct trie *t, int *err, u32 key, int 
plen)
        t->size++;
        l = leaf_new();
 
-       if (!l) {
-               *err = -ENOMEM;
-               goto done;
-       }
+       if (!l)
+               return NULL;
 
        l->key = key;
        li = leaf_info_new(plen);
 
        if (!li) {
                tnode_free((struct tnode *) l);
-               *err = -ENOMEM;
-               goto done;
+               return NULL;
        }
 
        fa_head = &li->falh;
@@ -1102,8 +1096,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int 
plen)
                if (!tn) {
                        free_leaf_info(li);
                        tnode_free((struct tnode *) l);
-                       *err = -ENOMEM;
-                       goto done;
+                       return NULL;
                }
 
                node_set_parent((struct node *)tn, tp);
@@ -1262,10 +1255,11 @@ static int fn_trie_insert(struct fib_table *tb, struct 
fib_config *cfg)
         */
 
        if (!fa_head) {
-               err = 0;
-               fa_head = fib_insert_node(t, &err, key, plen);
-               if (err)
+               fa_head = fib_insert_node(t, key, plen);
+               if (unlikely(!fa_head)) {
+                       err = -ENOMEM;
                        goto out_free_new_fa;
+               }
        }
 
        list_add_tail_rcu(&new_fa->fa_list,
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to