[PATCH] wanmain: comparing array with NULL

Subsystems: networking [general], the rest

STALE5133d

2 messages, 2 authors, 2012-07-24 · open the first message on its own page

[PATCH] wanmain: comparing array with NULL

From: Alan Cox <hidden>
Date: 2012-07-24 17:59:23

From: Alan Cox <redacted>

gcc really should warn about these !

Signed-off-by: Alan Cox <redacted>
---

 net/wanrouter/wanmain.c |   51 +++++++++++++++++++++--------------------------
 1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c
index 788a12c..23d6569 100644
--- a/net/wanrouter/wanmain.c
+++ b/net/wanrouter/wanmain.c
@@ -602,36 +602,31 @@ static int wanrouter_device_new_if(struct wan_device *wandev,
 		 * successfully, add it to the interface list.
 		 */
 
-		if (dev->name == NULL) {
-			err = -EINVAL;
-		} else {
-
-			#ifdef WANDEBUG
-			printk(KERN_INFO "%s: registering interface %s...\n",
+#ifdef WANDEBUG
+		printk(KERN_INFO "%s: registering interface %s...\n",
 				wanrouter_modname, dev->name);
-			#endif
-
-			err = register_netdev(dev);
-			if (!err) {
-				struct net_device *slave = NULL;
-				unsigned long smp_flags=0;
-
-				lock_adapter_irq(&wandev->lock, &smp_flags);
-
-				if (wandev->dev == NULL) {
-					wandev->dev = dev;
-				} else {
-					for (slave=wandev->dev;
-					     DEV_TO_SLAVE(slave);
-					     slave = DEV_TO_SLAVE(slave))
-						DEV_TO_SLAVE(slave) = dev;
-				}
-				++wandev->ndev;
-
-				unlock_adapter_irq(&wandev->lock, &smp_flags);
-				err = 0;	/* done !!! */
-				goto out;
+#endif
+
+		err = register_netdev(dev);
+		if (!err) {
+			struct net_device *slave = NULL;
+			unsigned long smp_flags=0;
+
+			lock_adapter_irq(&wandev->lock, &smp_flags);
+
+			if (wandev->dev == NULL) {
+				wandev->dev = dev;
+			} else {
+				for (slave=wandev->dev;
+				     DEV_TO_SLAVE(slave);
+				     slave = DEV_TO_SLAVE(slave))
+					DEV_TO_SLAVE(slave) = dev;
 			}
+			++wandev->ndev;
+
+			unlock_adapter_irq(&wandev->lock, &smp_flags);
+			err = 0;	/* done !!! */
+			goto out;
 		}
 		if (wandev->del_if)
 			wandev->del_if(wandev, dev);

Re: [PATCH] wanmain: comparing array with NULL

From: David Miller <davem@davemloft.net>
Date: 2012-07-24 20:57:44

From: Alan Cox <redacted>
Date: Tue, 24 Jul 2012 19:16:25 +0100
From: Alan Cox <redacted>

gcc really should warn about these !

Signed-off-by: Alan Cox <redacted>
Applied and queued up for -stable.
+		printk(KERN_INFO "%s: registering interface %s...\n",
 				wanrouter_modname, dev->name);
I adjusted the indentation of the second line, as needed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help