[RESEND] fs: namei: Use memcpy instead of strlcpy
diff mbox

Message ID 1421880265-26647-1-git-send-email-linux@roeck-us.net
State New, archived
Headers show

Commit Message

Guenter Roeck Jan. 21, 2015, 10:44 p.m. UTC
If the string length is known, there is no need to use strlcpy.
Use memcpy instead.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
Nitpick, but still a bit faster. Applies on top of -next.

Resending with correct cc:. Sorry for the noise.

 fs/namei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paul Moore Jan. 22, 2015, 12:44 a.m. UTC | #1
Good point.  Do you mind if I merge your patch into my existing patch 
instead of including it separately?

--
paul moore
www.paul-moore.com



On January 21, 2015 5:45:29 PM Guenter Roeck <linux@roeck-us.net> wrote:

> If the string length is known, there is no need to use strlcpy.
> Use memcpy instead.
>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> Nitpick, but still a bit faster. Applies on top of -next.
>
> Resending with correct cc:. Sorry for the noise.
>
>  fs/namei.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 323957f..2e09219 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -233,7 +233,7 @@ getname_kernel(const char * filename)
>  		__putname(result);
>  		return ERR_PTR(-ENAMETOOLONG);
>  	}
> -	strlcpy((char *)result->name, filename, len);
> +	memcpy((char *)result->name, filename, len);
>  	result->uptr = NULL;
>  	result->aname = NULL;
>  	result->refcnt = 1;
> --
> 2.1.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/


--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guenter Roeck Jan. 22, 2015, 1:59 a.m. UTC | #2
On 01/21/2015 04:44 PM, Paul Moore wrote:
> Good point.  Do you mind if I merge your patch into my existing patch instead of including it separately?
>
Sure, no problem. Go ahead.

Guenter

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" 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/fs/namei.c b/fs/namei.c
index 323957f..2e09219 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -233,7 +233,7 @@  getname_kernel(const char * filename)
 		__putname(result);
 		return ERR_PTR(-ENAMETOOLONG);
 	}
-	strlcpy((char *)result->name, filename, len);
+	memcpy((char *)result->name, filename, len);
 	result->uptr = NULL;
 	result->aname = NULL;
 	result->refcnt = 1;