Patchwork rds: use kmem_cache_zalloc instead of kmem_cache_alloc/memset

login
register
mail settings
Submitter Wei Yongjun
Date April 9, 2009, 8:02 a.m.
Message ID <49DDAB8A.5000300@cn.fujitsu.com>
Download mbox | patch
Permalink /patch/25773/
State Superseded
Delegated to: David Miller
Headers show

Comments

Wei Yongjun - April 9, 2009, 8:02 a.m.
Use kmem_cache_zalloc instead of kmem_cache_alloc/memset.

Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
 net/rds/connection.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
Andy Grover - April 9, 2009, 5:43 p.m.
Wei Yongjun wrote:
> Use kmem_cache_zalloc instead of kmem_cache_alloc/memset.
> 
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
>  net/rds/connection.c |    4 +---
>  1 files changed, 1 insertions(+), 3 deletions(-)
> 
> diff --git a/net/rds/connection.c b/net/rds/connection.c
> index 273f064..d14445c 100644
> --- a/net/rds/connection.c
> +++ b/net/rds/connection.c
> @@ -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;

Thanks, will include in next rds updates!

Regards -- Andy
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/rds/connection.c b/net/rds/connection.c
index 273f064..d14445c 100644
--- a/net/rds/connection.c
+++ b/net/rds/connection.c
@@ -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;