staging: lustre: obdclass: Replace kmem_cache_alloc with kmem_cache_zalloc
authorAmitoj Kaur Chawla <amitoj1606@gmail.com>
Fri, 26 Feb 2016 08:54:27 +0000 (14:24 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 2 Mar 2016 03:18:42 +0000 (19:18 -0800)
Use kmem_cache_zalloc instead of manually setting kmem_cache_alloc
with flag GFP_ZERO since kmem_alloc_zalloc sets allocated memory
to zero.

The Coccinelle semantic patch used to make this change is as
follows:
// <smpl>
@@
expression e,f;
@@
- kmem_cache_alloc(e, f |__GFP_ZERO)
+ kmem_cache_zalloc(e, f)
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/cl_lock.c
drivers/staging/lustre/lustre/obdclass/cl_object.c
drivers/staging/lustre/lustre/obdclass/genops.c

index 6cf284bb8ab54dc7eacc77745d77680ed204535b..f40a2ec691df45bde0cc4c41c9319ef8334f9124 100644 (file)
@@ -361,7 +361,7 @@ static struct cl_lock *cl_lock_alloc(const struct lu_env *env,
        struct cl_lock    *lock;
        struct lu_object_header *head;
 
-       lock = kmem_cache_alloc(cl_lock_kmem, GFP_NOFS | __GFP_ZERO);
+       lock = kmem_cache_zalloc(cl_lock_kmem, GFP_NOFS);
        if (lock) {
                atomic_set(&lock->cll_ref, 1);
                lock->cll_descr = *descr;
index e7c570ae48edd330fb1e7a566de9ac5cbd28bf98..43e299d4d416ad36c4c32cb98cee982c978e22f5 100644 (file)
@@ -659,7 +659,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
        struct lu_env *env;
        struct cl_env *cle;
 
-       cle = kmem_cache_alloc(cl_env_kmem, GFP_NOFS | __GFP_ZERO);
+       cle = kmem_cache_zalloc(cl_env_kmem, GFP_NOFS);
        if (cle) {
                int rc;
 
index 65f2c62502285bea4d33f8b41c9310d49afc1bb3..cf97b8f067640132f87a722c5415c5a14df7b60a 100644 (file)
@@ -69,7 +69,7 @@ static struct obd_device *obd_device_alloc(void)
 {
        struct obd_device *obd;
 
-       obd = kmem_cache_alloc(obd_device_cachep, GFP_NOFS | __GFP_ZERO);
+       obd = kmem_cache_zalloc(obd_device_cachep, GFP_NOFS);
        if (obd)
                obd->obd_magic = OBD_DEVICE_MAGIC;
        return obd;