staging: lustre: fld: Use !x to check for kzalloc failure
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 20 Jun 2015 16:59:00 +0000 (18:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:35:52 +0000 (19:35 -0700)
!x is more normal for kzalloc failure in the kernel.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x;
statement S1, S2;
@@

x = kzalloc(...);
if (
- x == NULL
+ !x
 ) S1 else S2
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/fld/fld_cache.c
drivers/staging/lustre/lustre/fld/fld_request.c

index ec2fc4339a2e752e1b29d04d7c1cdf9ae352915d..1b1066b2461ceadb6aeb01e7d12fe76d1b89fa83 100644 (file)
@@ -70,7 +70,7 @@ struct fld_cache *fld_cache_init(const char *name,
        LASSERT(cache_threshold < cache_size);
 
        cache = kzalloc(sizeof(*cache), GFP_NOFS);
-       if (cache == NULL)
+       if (!cache)
                return ERR_PTR(-ENOMEM);
 
        INIT_LIST_HEAD(&cache->fci_entries_head);
index c3b47f2346df6bd2e0a074869545e6ee0b7056ae..1e450bf953838ef75a996f21a71b3d487cce189d 100644 (file)
@@ -222,7 +222,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
                        fld->lcf_name, name, tar->ft_idx);
 
        target = kzalloc(sizeof(*target), GFP_NOFS);
-       if (target == NULL)
+       if (!target)
                return -ENOMEM;
 
        spin_lock(&fld->lcf_lock);