Re: [patch] 2.3.99-pre3-3: dev_alloc_name

From: Tim Waugh (twaugh@redhat.com)
Date: Tue Mar 21 2000 - 05:42:09 EST


On Mon, 20 Mar 2000, Jeff Garzik wrote:

> This is not correct, Linus please don't apply.

I think it is, Jeff. Try this patch:

Index: net/core/dev.c
===================================================================
RCS file: /usr/local/src/cvsroot/linux/net/core/dev.c,v
retrieving revision 1.1.1.18
diff -d -u -r1.1.1.18 dev.c
--- net/core/dev.c 2000/03/03 11:16:06 1.1.1.18
+++ net/core/dev.c 2000/03/21 10:26:38
@@ -358,7 +358,15 @@
         for (i = 0; i < 100; i++) {
                 sprintf(buf,name,i);
                 if (__dev_get_by_name(buf) == NULL) {
+ printk (KERN_DEBUG "this name: %s\n", dev->name);
+ if (dev->next)
+ printk (KERN_DEBUG
+ "next name: %s\n", dev->next->name);
                         strcpy(dev->name, buf);
+ printk (KERN_DEBUG "this name: %s\n", dev->name);
+ if (dev->next)
+ printk (KERN_DEBUG
+ "next name: %s\n", dev->next->name);
                         return i;
                 }
         }

With egcs-2.91.66 I get this:

this name: eth%d
next name: eth%d
this name: eth0
next name: eth0

I.e. the string literals in Space.c that look like "eth%d" are all in the
same place. Replacing 'strcpy(dev->name, buf)' with 'dev->name = strdup
(buf)' obviously gives the correct output:

this name: eth%d
next name: eth%d
this name: eth0
next name: eth%d

The next thing to fix is actually putting the command-line ether=
parameters _somewhere_. My plan for that is to assume that the user is
correct, and then to just count from the first '...%d' that we find in
dev_base. Does that sound right?

Tim.
*/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:32 EST