Skip to contentSkip to conversation

rds: use kmem_cache_zalloc instead of kmem_cache_alloc/memset

PATCH Wei Yongjun 2 participants 2 messages Apr 9, 2009

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Use kmem_cache_zalloc instead of kmem_cache_alloc/memset.

---
 net/rds/connection.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
net/rds/connection.c +1 -3
index 273f064..d14445c 100644
@@ -148,14 +148,12 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
 	if (conn)
 		goto out;
 
-	conn = kmem_cache_alloc(rds_conn_slab, gfp);
+	conn = kmem_cache_zalloc(rds_conn_slab, gfp);
 	if (conn == NULL) {
 		conn = ERR_PTR(-ENOMEM);
 		goto out;
 	}
 
-	memset(conn, 0, sizeof(*conn));
-
 	INIT_HLIST_NODE(&conn->c_hash_node);
 	conn->c_version = RDS_PROTOCOL_3_0;
 	conn->c_laddr = laddr;
Signature · 1 line
1.5.3.8
#1 lore raw
Quoted 17 lines · Wei Yongjun

Use kmem_cache_zalloc instead of kmem_cache_alloc/memset.

---
 net/rds/connection.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
net/rds/connection.c +1 -1
index 273f064..d14445c 100644
@@ -148,14 +148,12 @@ static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr,
 	if (conn)
 		goto out;
 
-	conn = kmem_cache_alloc(rds_conn_slab, gfp);
+	conn = kmem_cache_zalloc(rds_conn_slab, gfp);

net/rds/connection.c static struct rds_connection *__rds_conn_create(__be32 laddr, __be32 faddr, · line 159

Quoted 10 lines
net/rds/connection.c +0 -2
 	if (conn == NULL) {
 		conn = ERR_PTR(-ENOMEM);
 		goto out;
 	}
 
-	memset(conn, 0, sizeof(*conn));
-
 	INIT_HLIST_NODE(&conn->c_hash_node);
 	conn->c_version = RDS_PROTOCOL_3_0;
 	conn->c_laddr = laddr;

Thanks, will include in next rds updates!

Regards -- Andy