Skip to contentSkip to conversation

fs: namei: Use memcpy instead of strlcpy

PATCH RESEND In review Guenter Roeck 2 participants 3 messages Jan 21, 2015 – Jan 22, 2015 VFS

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 fs: namei: Use memcpy instead of strlcpy

If the string length is known, there is no need to use strlcpy. Use memcpy instead.

---
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(-)
fs/namei.c +1 -1
index 323957f..2e09219 100644
@@ -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;
Signature · 1 line
2.1.0
#1 lore raw

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

Quoted 33 lines · Guenter Roeck

If the string length is known, there is no need to use strlcpy. Use memcpy instead.

---
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(-)
fs/namei.c +1 -2
index 323957f..2e09219 100644
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
Quoted 2 lines · Paul Moore

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