| To: | "David S. Miller" <davem@xxxxxxxxxxxxx> |
|---|---|
| Subject: | [PATCH] dont use strlen() but the result from a prior sprintf() |
| From: | Eric Dumazet <dada1@xxxxxxxxxxxxx> |
| Date: | Wed, 22 Jun 2005 14:56:55 +0200 |
| Cc: | netdev@xxxxxxxxxxx |
| In-reply-to: | <20050621.165634.07642938.davem@xxxxxxxxxxxxx> |
| References: | <20050614154625.GB24371@xxxxxxxxxxxxxxxxx> <1118771563.7059.30.camel@rh4> <20050614211530.GB25516@xxxxxxxxxxxxxxxxx> <20050621.165634.07642938.davem@xxxxxxxxxxxxx> |
| Sender: | netdev-bounce@xxxxxxxxxxx |
| User-agent: | Mozilla Thunderbird 1.0 (Windows/20041206) |
Hi David
Small patch to save an unecessary call to strlen() : sprintf() gave us the
length, just trust it.
Thank you
Eric Dumazet
diff -Nu linux-2.6.12-orig/net/socket.c linux-2.6.12/net/socket.c
--- linux-2.6.12-orig/net/socket.c 2005-06-22 14:47:56.000000000 +0200
+++ linux-2.6.12/net/socket.c 2005-06-22 14:49:22.000000000 +0200
@@ -382,9 +382,8 @@
goto out;
}
- sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
+ this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
this.name = name;
- this.len = strlen(name);
this.hash = SOCK_INODE(sock)->i_ino;
file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
--- linux-2.6.12-orig/net/socket.c 2005-06-22 14:47:56.000000000 +0200
+++ linux-2.6.12/net/socket.c 2005-06-22 14:49:22.000000000 +0200
@@ -382,9 +382,8 @@
goto out;
}
- sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
+ this.len = sprintf(name, "[%lu]", SOCK_INODE(sock)->i_ino);
this.name = name;
- this.len = strlen(name);
this.hash = SOCK_INODE(sock)->i_ino;
file->f_dentry = d_alloc(sock_mnt->mnt_sb->s_root, &this);
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [patch,rfc] allow registration of multiple netpolls per interface, Jeff Moyer |
|---|---|
| Next by Date: | Print one record only - addition, Tomáš Macek |
| Previous by Thread: | Re: [PATCH] tg3_msi() and weakly ordered memory, Grant Grundler |
| Next by Thread: | Re: [PATCH] tg3_msi() and weakly ordered memory, Grant Grundler |
| Indexes: | [Date] [Thread] [Top] [All Lists] |