Re: [PATCH] IPv6: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2

2006-03-16 Thread David S. Miller
From: Ingo Oeser <[EMAIL PROTECTED]>
Date: Fri, 10 Mar 2006 23:34:26 +0100

> 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 <[EMAIL PROTECTED]>
> Acked-by: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>

Applied, thanks a lot Ingo.
-
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


Re: [PATCH] IPv6: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2

2006-03-10 Thread Ingo Oeser
From: Ingo Oeser <[EMAIL PROTECTED]>

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 <[EMAIL PROTECTED]>
Acked-by: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>

---
Hello Dave,

On Friday, 10. March 2006 12:02, David S. Miller wrote:
> This patch no longer applied cleanly, Ingo can you generate
> a fresh version of your patch against my net-2.6.16 tree?

Done!

I rebased it, but against net-2.6.17, since it did apply cleanly to
net-2.6 and I didn't find the tree for net-2.6.16 as requested.

Hope I got it right :-)

Regards 

Ingo Oeser

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 8df9eb9..395b3f8 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -341,84 +341,83 @@ static struct inet6_dev * ipv6_add_dev(s
if (dev->mtu < IPV6_MIN_MTU)
return NULL;
 
-   ndev = kmalloc(sizeof(struct inet6_dev), GFP_KERNEL);
-
-   if (ndev) {
-   memset(ndev, 0, sizeof(struct inet6_dev));
-
-   rwlock_init(&ndev->lock);
-   ndev->dev = dev;
-   memcpy(&ndev->cnf, &ipv6_devconf_dflt, sizeof(ndev->cnf));
-   ndev->cnf.mtu6 = dev->mtu;
-   ndev->cnf.sysctl = NULL;
-   ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
-   if (ndev->nd_parms == NULL) {
-   kfree(ndev);
-   return NULL;
-   }
-   /* We refer to the device */
-   dev_hold(dev);
+   ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
+  
+   if (ndev == NULL)
+   return NULL;
+
+   rwlock_init(&ndev->lock);
+   ndev->dev = dev;
+   memcpy(&ndev->cnf, &ipv6_devconf_dflt, sizeof(ndev->cnf));
+   ndev->cnf.mtu6 = dev->mtu;
+   ndev->cnf.sysctl = NULL;
+   ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
+   if (ndev->nd_parms == NULL) {
+   kfree(ndev);
+   return NULL;
+   }
+   /* We refer to the device */
+   dev_hold(dev);
 
-   if (snmp6_alloc_dev(ndev) < 0) {
-   ADBG((KERN_WARNING
-   "%s(): cannot allocate memory for statistics; 
dev=%s.\n",
-   __FUNCTION__, dev->name));
-   neigh_parms_release(&nd_tbl, ndev->nd_parms);
-   ndev->dead = 1;
-   in6_dev_finish_destroy(ndev);
-   return NULL;
-   }
+   if (snmp6_alloc_dev(ndev) < 0) {
+   ADBG((KERN_WARNING
+   "%s(): cannot allocate memory for statistics; 
dev=%s.\n",
+   __FUNCTION__, dev->name));
+   neigh_parms_release(&nd_tbl, ndev->nd_parms);
+   ndev->dead = 1;
+   in6_dev_finish_destroy(ndev);
+   return NULL;
+   }
 
-   if (snmp6_register_dev(ndev) < 0) {
-   ADBG((KERN_WARNING
-   "%s(): cannot create /proc/net/dev_snmp6/%s\n",
-   __FUNCTION__, dev->name));
-   neigh_parms_release(&nd_tbl, ndev->nd_parms);
-   ndev->dead = 1;
-   in6_dev_finish_destroy(ndev);
-   return NULL;
-   }
+   if (snmp6_register_dev(ndev) < 0) {
+   ADBG((KERN_WARNING
+   "%s(): cannot create /proc/net/dev_snmp6/%s\n",
+   __FUNCTION__, dev->name));
+   neigh_parms_release(&nd_tbl, ndev->nd_parms);
+   ndev->dead = 1;
+   in6_dev_finish_destroy(ndev);
+   return NULL;
+   }
 
-   /* One reference from device.  We must do this before
-* we invoke __ipv6_regen_rndid().
-*/
-   in6_dev_hold(ndev);
+   /* One reference from device.  We must do this before
+* we invoke __ipv6_regen_rndid().
+*/
+   in6_dev_hold(ndev);
 
 #ifdef CONFIG_IPV6_PRIVACY
-   init_timer(&ndev->regen_timer);
-   ndev->regen_timer.function = ipv6_regen_rndid;
-   ndev->regen_timer.data = (unsigned long) ndev;
-   if ((dev->flags&IFF_LOOPBACK) ||
-   dev->type == ARPHRD_TUNNEL ||
-   dev->type == ARPHRD_NONE ||
-   dev->type == ARPHRD_SIT) {
-   printk(KERN_INFO
-  "%s: Disabled Privacy Extensions\n",
-  dev->name);
-   ndev->cnf.use_tempaddr = -1;
-   } else {
-   in6_dev_hold(ndev);
-   ipv6_regen_rndid((unsigned long) ndev);
- 

Re: [PATCH] IPv6: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2

2006-03-10 Thread David S. Miller
From: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>
Date: Sun, 12 Feb 2006 02:11:03 +0900 (JST)

> In article <[EMAIL PROTECTED]> (at Sat, 11 Feb 2006 17:37:18 +0100), Ingo 
> Oeser <[EMAIL PROTECTED]> says:
> 
> > From: Ingo Oeser <[EMAIL PROTECTED]>
> > 
> > Here are some possible (and trivial) cleanups.
> > - use kzalloc() where possible
> > - remove unused label
> > - invert allocation failure test like
> :
> > Signed-off-by: Ingo Oeser <[EMAIL PROTECTED]>
> Acked-by: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>

This patch no longer applied cleanly, Ingo can you generate
a fresh version of your patch against my net-2.6.16 tree?

Thanks a lot!
-
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


Re: [PATCH] IPv6: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2

2006-02-11 Thread YOSHIFUJI Hideaki / 吉藤英明
Hello.

In article <[EMAIL PROTECTED]> (at Sat, 11 Feb 2006 17:37:18 +0100), Ingo Oeser 
<[EMAIL PROTECTED]> says:

> From: Ingo Oeser <[EMAIL PROTECTED]>
> 
> Here are some possible (and trivial) cleanups.
> - use kzalloc() where possible
> - remove unused label
> - invert allocation failure test like
:
> Signed-off-by: Ingo Oeser <[EMAIL PROTECTED]>
Acked-by: YOSHIFUJI Hideaki <[EMAIL PROTECTED]>

--yoshfuji
-
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


[PATCH] IPv6: Cleanups for net/ipv6/addrconf.c (kzalloc, early exit) v2

2006-02-11 Thread Ingo Oeser
From: Ingo Oeser <[EMAIL PROTECTED]>

Here are some possible (and trivial) cleanups.
- use kzalloc() where possible
- remove unused label
- invert allocation failure test like
  if (object) {
/* Rest of function here */
  }
  to

  if (object == NULL)
return NULL;

  /* Rest of function here */

The last one moves quite some code, because it changes indention.
I can split that up, if needed.

Signed-off-by: Ingo Oeser <[EMAIL PROTECTED]>
---
Hello,

On Thursday 09 February 2006 17:48, YOSHIFUJI Hideaki wrote:
> Please keep nlmsg_failure, which is used by NLMSG_NEW().

This issue has been adressed now. 

Patch is against latest git from Linus. It has been compile tested with
allyesconfig on ix86.

Many thanks for your patience!

Regards

Ingo Oeer

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index b7d8822..984a9bc 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -327,86 +327,85 @@ static struct inet6_dev * ipv6_add_dev(s
if (dev->mtu < IPV6_MIN_MTU)
return NULL;
 
-   ndev = kmalloc(sizeof(struct inet6_dev), GFP_KERNEL);
+   ndev = kzalloc(sizeof(struct inet6_dev), GFP_KERNEL);
 
-   if (ndev) {
-   memset(ndev, 0, sizeof(struct inet6_dev));
+   if (ndev == NULL)
+   return NULL;
 
-   rwlock_init(&ndev->lock);
-   ndev->dev = dev;
-   memcpy(&ndev->cnf, &ipv6_devconf_dflt, sizeof(ndev->cnf));
-   ndev->cnf.mtu6 = dev->mtu;
-   ndev->cnf.sysctl = NULL;
-   ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
-   if (ndev->nd_parms == NULL) {
-   kfree(ndev);
-   return NULL;
-   }
-   /* We refer to the device */
-   dev_hold(dev);
+   rwlock_init(&ndev->lock);
+   ndev->dev = dev;
+   memcpy(&ndev->cnf, &ipv6_devconf_dflt, sizeof(ndev->cnf));
+   ndev->cnf.mtu6 = dev->mtu;
+   ndev->cnf.sysctl = NULL;
+   ndev->nd_parms = neigh_parms_alloc(dev, &nd_tbl);
+   if (ndev->nd_parms == NULL) {
+   kfree(ndev);
+   return NULL;
+   }
+   /* We refer to the device */
+   dev_hold(dev);
 
-   if (snmp6_alloc_dev(ndev) < 0) {
-   ADBG((KERN_WARNING
-   "%s(): cannot allocate memory for statistics; 
dev=%s.\n",
-   __FUNCTION__, dev->name));
-   neigh_parms_release(&nd_tbl, ndev->nd_parms);
-   ndev->dead = 1;
-   in6_dev_finish_destroy(ndev);
-   return NULL;
-   }
+   if (snmp6_alloc_dev(ndev) < 0) {
+   ADBG((KERN_WARNING
+   "%s(): cannot allocate memory for statistics; 
dev=%s.\n",
+   __FUNCTION__, dev->name));
+   neigh_parms_release(&nd_tbl, ndev->nd_parms);
+   ndev->dead = 1;
+   in6_dev_finish_destroy(ndev);
+   return NULL;
+   }
 
-   if (snmp6_register_dev(ndev) < 0) {
-   ADBG((KERN_WARNING
-   "%s(): cannot create /proc/net/dev_snmp6/%s\n",
-   __FUNCTION__, dev->name));
-   neigh_parms_release(&nd_tbl, ndev->nd_parms);
-   ndev->dead = 1;
-   in6_dev_finish_destroy(ndev);
-   return NULL;
-   }
+   if (snmp6_register_dev(ndev) < 0) {
+   ADBG((KERN_WARNING
+   "%s(): cannot create /proc/net/dev_snmp6/%s\n",
+   __FUNCTION__, dev->name));
+   neigh_parms_release(&nd_tbl, ndev->nd_parms);
+   ndev->dead = 1;
+   in6_dev_finish_destroy(ndev);
+   return NULL;
+   }
 
-   /* One reference from device.  We must do this before
-* we invoke __ipv6_regen_rndid().
-*/
-   in6_dev_hold(ndev);
+   /* One reference from device.  We must do this before
+* we invoke __ipv6_regen_rndid().
+*/
+   in6_dev_hold(ndev);
 
 #ifdef CONFIG_IPV6_PRIVACY
-   get_random_bytes(ndev->rndid, sizeof(ndev->rndid));
-   get_random_bytes(ndev->entropy, sizeof(ndev->entropy));
-   init_timer(&ndev->regen_timer);
-   ndev->regen_timer.function = ipv6_regen_rndid;
-   ndev->regen_timer.data = (unsigned long) ndev;
-   if ((dev->flags&IFF_LOOPBACK) ||
-   dev->type == ARPHRD_TUNNEL ||
-   dev->type == ARPHRD_NONE ||
-   dev->type == ARPHRD_SIT) {
-   printk(KERN_INFO
-  "%s: Disabled Privacy Extensions\n",
-  dev->name);
-   ndev->cnf.use_tempaddr = -1;
-