Skip to contentSkip to conversation

ceph: Use kmemdup rather than duplicating its implementation

PATCH Applied Thomas Meyer 2 participants 2 messages Nov 10, 2011 – Nov 11, 2011 Ceph common code (libceph)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: Use kmemdup rather than duplicating its implementation

Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.

---

net/ceph/crypto.c 2011-11-08 10:58:06.915274800 +0100 renamed from net/ceph/crypto.c 2011-11-07 19:38:30.130592543 +0100 +1 -2
diff -u -p a/net/ceph/crypto.c b/net/ceph/crypto.c
@@ -15,10 +15,9 @@ int ceph_crypto_key_clone(struct ceph_cr
 			  const struct ceph_crypto_key *src)
 {
 	memcpy(dst, src, sizeof(struct ceph_crypto_key));
-	dst->key = kmalloc(src->len, GFP_NOFS);
+	dst->key = kmemdup(src->key, src->len, GFP_NOFS);
 	if (!dst->key)
 		return -ENOMEM;
-	memcpy(dst->key, src->key, src->len);
 	return 0;
 }
 
Applied
#1 lore raw

Applied, thanks!

Quoted 31 lines · Thomas Meyer

Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.

---

diff -u -p a/net/ceph/crypto.c b/net/ceph/crypto.c

net/ceph/crypto.c 2011-11-08 10:58:06.915274800 +0100 renamed from net/ceph/crypto.c 2011-11-07 19:38:30.130592543 +0100 +1 -3
@@ -15,10 +15,9 @@ int ceph_crypto_key_clone(struct ceph_cr
 			  const struct ceph_crypto_key *src)
 {
 	memcpy(dst, src, sizeof(struct ceph_crypto_key));
-	dst->key = kmalloc(src->len, GFP_NOFS);
+	dst->key = kmemdup(src->key, src->len, GFP_NOFS);
 	if (!dst->key)
 		return -ENOMEM;
-	memcpy(dst->key, src->key, src->len);
 	return 0;
 }
 
 
 
--

To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html