diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2007-12-01 08:06:34 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:55:24 -0500 |
commit | 3c607bbb472814f01b077af01ae326944ff6b8b3 (patch) | |
tree | 0b6097274f25c8c0cfe180c8da640c68c9781af6 /net/core/neighbour.c | |
parent | 1597fbc0faf88c42edb3fe42e92e53b83c3f120e (diff) |
[NEIGH]: Cleanup the neigh_sysctl_register
This mainly removes the err variable, as this call always
return the same error code (-ENOBUFS).
Besides, I moved the call to kmalloc() from the *t declaration
into the code (this is confusing when a variable is initialized
with the result of some call) and removed unneeded comment near
the error path.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r-- | net/core/neighbour.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index a8b72c1c7c8a..5dbe26f460d6 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -2652,14 +2652,14 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
2652 | int p_id, int pdev_id, char *p_name, | 2652 | int p_id, int pdev_id, char *p_name, |
2653 | proc_handler *handler, ctl_handler *strategy) | 2653 | proc_handler *handler, ctl_handler *strategy) |
2654 | { | 2654 | { |
2655 | struct neigh_sysctl_table *t = kmemdup(&neigh_sysctl_template, | 2655 | struct neigh_sysctl_table *t; |
2656 | sizeof(*t), GFP_KERNEL); | ||
2657 | const char *dev_name_source = NULL; | 2656 | const char *dev_name_source = NULL; |
2658 | char *dev_name = NULL; | 2657 | char *dev_name = NULL; |
2659 | int err = 0; | ||
2660 | 2658 | ||
2659 | t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL); | ||
2661 | if (!t) | 2660 | if (!t) |
2662 | return -ENOBUFS; | 2661 | goto err; |
2662 | |||
2663 | t->neigh_vars[0].data = &p->mcast_probes; | 2663 | t->neigh_vars[0].data = &p->mcast_probes; |
2664 | t->neigh_vars[1].data = &p->ucast_probes; | 2664 | t->neigh_vars[1].data = &p->ucast_probes; |
2665 | t->neigh_vars[2].data = &p->app_probes; | 2665 | t->neigh_vars[2].data = &p->app_probes; |
@@ -2717,10 +2717,8 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
2717 | } | 2717 | } |
2718 | 2718 | ||
2719 | dev_name = kstrdup(dev_name_source, GFP_KERNEL); | 2719 | dev_name = kstrdup(dev_name_source, GFP_KERNEL); |
2720 | if (!dev_name) { | 2720 | if (!dev_name) |
2721 | err = -ENOBUFS; | ||
2722 | goto free; | 2721 | goto free; |
2723 | } | ||
2724 | 2722 | ||
2725 | t->neigh_dev[0].procname = dev_name; | 2723 | t->neigh_dev[0].procname = dev_name; |
2726 | 2724 | ||
@@ -2735,20 +2733,18 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
2735 | t->neigh_root_dir[0].child = t->neigh_proto_dir; | 2733 | t->neigh_root_dir[0].child = t->neigh_proto_dir; |
2736 | 2734 | ||
2737 | t->sysctl_header = register_sysctl_table(t->neigh_root_dir); | 2735 | t->sysctl_header = register_sysctl_table(t->neigh_root_dir); |
2738 | if (!t->sysctl_header) { | 2736 | if (!t->sysctl_header) |
2739 | err = -ENOBUFS; | ||
2740 | goto free_procname; | 2737 | goto free_procname; |
2741 | } | 2738 | |
2742 | p->sysctl_table = t; | 2739 | p->sysctl_table = t; |
2743 | return 0; | 2740 | return 0; |
2744 | 2741 | ||
2745 | /* error path */ | 2742 | free_procname: |
2746 | free_procname: | ||
2747 | kfree(dev_name); | 2743 | kfree(dev_name); |
2748 | free: | 2744 | free: |
2749 | kfree(t); | 2745 | kfree(t); |
2750 | 2746 | err: | |
2751 | return err; | 2747 | return -ENOBUFS; |
2752 | } | 2748 | } |
2753 | 2749 | ||
2754 | void neigh_sysctl_unregister(struct neigh_parms *p) | 2750 | void neigh_sysctl_unregister(struct neigh_parms *p) |