net: A little dev_valid_name() improvement
diff mbox

Message ID 8496f91a0901181107o17ee80e7h7fab67194a7bde23@mail.gmail.com
State Rejected, archived
Delegated to: David Miller
Headers show

Commit Message

Matvejchikov Ilya Jan. 18, 2009, 7:07 p.m. UTC
This patch removes redundant complexity when checking the
network device name to be valid.

Signed-off-by: Matvejchikov Ilya <matvejchikov@gmail.com>
---
 net/core/dev.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

 		if (*name == '/' || isspace(*name))

Comments

Michael Tokarev Jan. 18, 2009, 8:28 p.m. UTC | #1
Matvejchikov Ilya wrote:
> This patch removes redundant complexity when checking the
> network device name to be valid.

And also disallows any name starting with a dot, while
previously it was allowed/valid.

I don't think this patch is good.

/mjt

> -	if (*name == '\0')
> +	if (*name == '\0' || *name == '.')
>  		return 0;
> -	if (!strcmp(name, ".") || !strcmp(name, ".."))
> -		return 0;

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Jan. 19, 2009, 2:17 a.m. UTC | #2
From: Michael Tokarev <mjt@tls.msk.ru>
Date: Sun, 18 Jan 2009 23:28:46 +0300

> Matvejchikov Ilya wrote:
> > This patch removes redundant complexity when checking the
> > network device name to be valid.
> 
> And also disallows any name starting with a dot, while
> previously it was allowed/valid.
> 
> I don't think this patch is good.

Agreed, I'm not applying this.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/net/core/dev.c b/net/core/dev.c
index 8d67597..9c5d8f4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -760,12 +760,10 @@  struct net_device * dev_get_by_flags(struct net
*net, unsigned short if_flags, u
  */
 int dev_valid_name(const char *name)
 {
-	if (*name == '\0')
+	if (*name == '\0' || *name == '.')
 		return 0;
 	if (strlen(name) >= IFNAMSIZ)
 		return 0;
-	if (!strcmp(name, ".") || !strcmp(name, ".."))
-		return 0;

 	while (*name) {