mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] string: make kmemdup_nul take and return void*, not char*
@ 2018-09-07  7:46 Rasmus Villemoes
  2018-09-07  7:46 ` [PATCH 2/2] rxrpc: use kmemdup_nul in rxrpc_krb5_decode_principal Rasmus Villemoes
  2018-09-18  7:15 ` [PATCH 1/2] string: make kmemdup_nul take and return void*, not char* Rasmus Villemoes
  0 siblings, 2 replies; 3+ messages in thread
From: Rasmus Villemoes @ 2018-09-07  7:46 UTC (permalink / raw)
  To: David Howells; +Cc: linux-kernel, Andrew Morton, Rasmus Villemoes

This allows kmemdup_nul to be used in cases where the source pointer is
not a char* or const char*, but the result should nevertheless have a
nul char after the memcpy'ed data.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/string.h | 2 +-
 mm/util.c              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/string.h b/include/linux/string.h
index 4a5a0eb7df51..b44a2254bc6b 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -169,7 +169,7 @@ extern char *kstrdup(const char *s, gfp_t gfp) __malloc;
 extern const char *kstrdup_const(const char *s, gfp_t gfp);
 extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
 extern void *kmemdup(const void *src, size_t len, gfp_t gfp);
-extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
+extern void *kmemdup_nul(const void *s, size_t len, gfp_t gfp);
 
 extern char **argv_split(gfp_t gfp, const char *str, int *argcp);
 extern void argv_free(char **argv);
diff --git a/mm/util.c b/mm/util.c
index 9e3ebd2ef65f..15ef23f1176e 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -128,7 +128,7 @@ EXPORT_SYMBOL(kmemdup);
  * @len: The size of the data
  * @gfp: the GFP mask used in the kmalloc() call when allocating memory
  */
-char *kmemdup_nul(const char *s, size_t len, gfp_t gfp)
+void *kmemdup_nul(const void *s, size_t len, gfp_t gfp)
 {
 	char *buf;
 
-- 
2.16.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-18  7:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07  7:46 [PATCH 1/2] string: make kmemdup_nul take and return void*, not char* Rasmus Villemoes
2018-09-07  7:46 ` [PATCH 2/2] rxrpc: use kmemdup_nul in rxrpc_krb5_decode_principal Rasmus Villemoes
2018-09-18  7:15 ` [PATCH 1/2] string: make kmemdup_nul take and return void*, not char* Rasmus Villemoes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®