All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] slip: remove dead code within the slip initialization
@ 2011-07-13  7:47 Matvejchikov Ilya
  2011-07-13  9:32 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Matvejchikov Ilya @ 2011-07-13  7:47 UTC (permalink / raw)
  To: netdev; +Cc: matvejchikov

This following code contains a dead "if (dev).." block:
        ...
        for (i = 0; i < slip_maxdev; i++) {
                dev = slip_devs[i];
                if (dev == NULL)
                        break;
        }
        /* Sorry, too many, all slots in use */
        if (i >= slip_maxdev)
                return NULL;

        if (dev) {
                sl = netdev_priv(dev);
                if (test_bit(SLF_INUSE, &sl->flags)) {
                        unregister_netdevice(dev);
                        dev = NULL;
                        slip_devs[i] = NULL;
                }
         }
        ...
The reason is that the code starting with "if (dev).." is never called as
when we found an empty slot (dev == NULL) we break the loop and "if (dev).."
not works eiter the loop ends and we get out with "i >= slip_maxdev".

Signed-off-by: Matvejchikov Ilya <matvejchikov@gmail.com>
---
 drivers/net/slip.c |   24 ++++++------------------
 1 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 6f97c59..11c9ab3 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -723,6 +723,7 @@ static void sl_sync(void)
 static struct slip *sl_alloc(dev_t line)
 {
 	int i;
+	char name[IFNAMSIZ];
 	struct net_device *dev = NULL;
 	struct slip       *sl;

@@ -735,25 +736,12 @@ static struct slip *sl_alloc(dev_t line)
 	if (i >= slip_maxdev)
 		return NULL;

-	if (dev) {
-		sl = netdev_priv(dev);
-		if (test_bit(SLF_INUSE, &sl->flags)) {
-			unregister_netdevice(dev);
-			dev = NULL;
-			slip_devs[i] = NULL;
-		}
-	}
-
-	if (!dev) {
-		char name[IFNAMSIZ];
-		sprintf(name, "sl%d", i);
-
-		dev = alloc_netdev(sizeof(*sl), name, sl_setup);
-		if (!dev)
-			return NULL;
-		dev->base_addr  = i;
-	}
+	sprintf(name, "sl%d", i);
+	dev = alloc_netdev(sizeof(*sl), name, sl_setup);
+	if (!dev)
+		return NULL;

+	dev->base_addr  = i;
 	sl = netdev_priv(dev);

 	/* Initialize channel control data */
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 4/4] slip: remove dead code within the slip initialization
  2011-07-13  7:47 [PATCH 4/4] slip: remove dead code within the slip initialization Matvejchikov Ilya
@ 2011-07-13  9:32 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-07-13  9:32 UTC (permalink / raw)
  To: matvejchikov; +Cc: netdev

From: Matvejchikov Ilya <matvejchikov@gmail.com>
Date: Wed, 13 Jul 2011 11:47:38 +0400

> This following code contains a dead "if (dev).." block:
...
> The reason is that the code starting with "if (dev).." is never called as
> when we found an empty slot (dev == NULL) we break the loop and "if (dev).."
> not works eiter the loop ends and we get out with "i >= slip_maxdev".
> 
> Signed-off-by: Matvejchikov Ilya <matvejchikov@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-07-13  9:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13  7:47 [PATCH 4/4] slip: remove dead code within the slip initialization Matvejchikov Ilya
2011-07-13  9:32 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.