[IPV6]: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2
Here are some possible (and trivial) cleanups. - use kzalloc() where possible - invert allocation failure test like if (object) { /* Rest of function here */ } to if (object == NULL) return NULL; /* Rest of function here */ Signed-off-by: Ingo Oeser <ioe-lkml@rameria.de> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
0c600eda4b
commit
322f74a432
@@ -341,10 +341,10 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
|||||||
if (dev->mtu < IPV6_MIN_MTU)
|
if (dev->mtu < IPV6_MIN_MTU)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ndev = kmalloc(sizeof(struct inet6_dev), GFP_KERNEL);
|
ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
|
||||||
|
|
||||||
if (ndev) {
|
if (ndev == NULL)
|
||||||
memset(ndev, 0, sizeof(struct inet6_dev));
|
return NULL;
|
||||||
|
|
||||||
rwlock_init(&ndev->lock);
|
rwlock_init(&ndev->lock);
|
||||||
ndev->dev = dev;
|
ndev->dev = dev;
|
||||||
@@ -418,7 +418,6 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
|||||||
NULL);
|
NULL);
|
||||||
addrconf_sysctl_register(ndev, &ndev->cnf);
|
addrconf_sysctl_register(ndev, &ndev->cnf);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
return ndev;
|
return ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,7 +535,7 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ifa = kmalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);
|
ifa = kzalloc(sizeof(struct inet6_ifaddr), GFP_ATOMIC);
|
||||||
|
|
||||||
if (ifa == NULL) {
|
if (ifa == NULL) {
|
||||||
ADBG(("ipv6_add_addr: malloc failed\n"));
|
ADBG(("ipv6_add_addr: malloc failed\n"));
|
||||||
@@ -550,7 +549,6 @@ ipv6_add_addr(struct inet6_dev *idev, const struct in6_addr *addr, int pfxlen,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(ifa, 0, sizeof(struct inet6_ifaddr));
|
|
||||||
ipv6_addr_copy(&ifa->addr, addr);
|
ipv6_addr_copy(&ifa->addr, addr);
|
||||||
|
|
||||||
spin_lock_init(&ifa->lock);
|
spin_lock_init(&ifa->lock);
|
||||||
@@ -2669,11 +2667,10 @@ static int if6_seq_open(struct inode *inode, struct file *file)
|
|||||||
{
|
{
|
||||||
struct seq_file *seq;
|
struct seq_file *seq;
|
||||||
int rc = -ENOMEM;
|
int rc = -ENOMEM;
|
||||||
struct if6_iter_state *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
struct if6_iter_state *s = kzalloc(sizeof(*s), GFP_KERNEL);
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
goto out;
|
goto out;
|
||||||
memset(s, 0, sizeof(*s));
|
|
||||||
|
|
||||||
rc = seq_open(file, &if6_seq_ops);
|
rc = seq_open(file, &if6_seq_ops);
|
||||||
if (rc)
|
if (rc)
|
||||||
|
Reference in New Issue
Block a user