staging: lustre: osc: Use !x to check for kzalloc failure
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 20 Jun 2015 16:59:09 +0000 (18:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:35:53 +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/osc/osc_dev.c
drivers/staging/lustre/lustre/osc/osc_request.c

index 9222c9f4faae5c15298750646e27377ca99bae28..91fdec44792b097edf45b7a2d80bcdc2dd7e90b8 100644 (file)
@@ -218,7 +218,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env,
        int rc;
 
        od = kzalloc(sizeof(*od), GFP_NOFS);
-       if (od == NULL)
+       if (!od)
                return ERR_PTR(-ENOMEM);
 
        cl_device_init(&od->od_cl, t);
index f84b4c78a8a0a3f3ef8f2351115225e2f948ddd9..96c80e9bf92d4a5faf403b95afc78707e56fef68 100644 (file)
@@ -119,7 +119,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
 
        if (*lmmp == NULL) {
                *lmmp = kzalloc(lmm_size, GFP_NOFS);
-               if (*lmmp == NULL)
+               if (!*lmmp)
                        return -ENOMEM;
        }
 
@@ -1909,7 +1909,7 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
                mpflag = cfs_memory_pressure_get_and_set();
 
        crattr = kzalloc(sizeof(*crattr), GFP_NOFS);
-       if (crattr == NULL) {
+       if (!crattr) {
                rc = -ENOMEM;
                goto out;
        }