aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-01-12 23:57:07 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:01:54 -0500
commitfea86ad8123df0d49188cbc1dd2f48da6ae49d65 (patch)
treeb1a9b991d0e5eddb264a3cc08f8e4e8647ccad0a
parent187b5188a78694fa6608fa1252d5197a7b3ab076 (diff)
[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 <stephen.hemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/fib_trie.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index f5c046b517e4..e047de6873bd 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)
980 980
981/* only used from updater-side */ 981/* only used from updater-side */
982 982
983static struct list_head * 983static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen)
984fib_insert_node(struct trie *t, int *err, u32 key, int plen)
985{ 984{
986 int pos, newpos; 985 int pos, newpos;
987 struct tnode *tp = NULL, *tn = NULL; 986 struct tnode *tp = NULL, *tn = NULL;
@@ -1043,10 +1042,8 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1043 1042
1044 li = leaf_info_new(plen); 1043 li = leaf_info_new(plen);
1045 1044
1046 if (!li) { 1045 if (!li)
1047 *err = -ENOMEM; 1046 return NULL;
1048 goto done;
1049 }
1050 1047
1051 fa_head = &li->falh; 1048 fa_head = &li->falh;
1052 insert_leaf_info(&l->list, li); 1049 insert_leaf_info(&l->list, li);
@@ -1055,18 +1052,15 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1055 t->size++; 1052 t->size++;
1056 l = leaf_new(); 1053 l = leaf_new();
1057 1054
1058 if (!l) { 1055 if (!l)
1059 *err = -ENOMEM; 1056 return NULL;
1060 goto done;
1061 }
1062 1057
1063 l->key = key; 1058 l->key = key;
1064 li = leaf_info_new(plen); 1059 li = leaf_info_new(plen);
1065 1060
1066 if (!li) { 1061 if (!li) {
1067 tnode_free((struct tnode *) l); 1062 tnode_free((struct tnode *) l);
1068 *err = -ENOMEM; 1063 return NULL;
1069 goto done;
1070 } 1064 }
1071 1065
1072 fa_head = &li->falh; 1066 fa_head = &li->falh;
@@ -1102,8 +1096,7 @@ fib_insert_node(struct trie *t, int *err, u32 key, int plen)
1102 if (!tn) { 1096 if (!tn) {
1103 free_leaf_info(li); 1097 free_leaf_info(li);
1104 tnode_free((struct tnode *) l); 1098 tnode_free((struct tnode *) l);
1105 *err = -ENOMEM; 1099 return NULL;
1106 goto done;
1107 } 1100 }
1108 1101
1109 node_set_parent((struct node *)tn, tp); 1102 node_set_parent((struct node *)tn, tp);
@@ -1262,10 +1255,11 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1262 */ 1255 */
1263 1256
1264 if (!fa_head) { 1257 if (!fa_head) {
1265 err = 0; 1258 fa_head = fib_insert_node(t, key, plen);
1266 fa_head = fib_insert_node(t, &err, key, plen); 1259 if (unlikely(!fa_head)) {
1267 if (err) 1260 err = -ENOMEM;
1268 goto out_free_new_fa; 1261 goto out_free_new_fa;
1262 }
1269 } 1263 }
1270 1264
1271 list_add_tail_rcu(&new_fa->fa_list, 1265 list_add_tail_rcu(&new_fa->fa_list,