staging: lustre: lov: Use !x to check for kzalloc failure
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sat, 20 Jun 2015 16:59:04 +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/lov/lov_dev.c
drivers/staging/lustre/lustre/lov/lov_io.c
drivers/staging/lustre/lustre/lov/lov_obd.c
drivers/staging/lustre/lustre/lov/lov_pool.c
drivers/staging/lustre/lustre/lov/lov_request.c

index 504b24a468fc13bbd614d52aed9040e09eb16033..8c3bbe574723cc54f4a4d1adf104560d4981ea24 100644 (file)
@@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
        int rc;
 
        ld = kzalloc(sizeof(*ld), GFP_NOFS);
-       if (ld == NULL)
+       if (!ld)
                return ERR_PTR(-ENOMEM);
 
        cl_device_init(&ld->ld_cl, t);
index 11c1081b1d3df9f7935fba82376c357e81bdd5ed..bf3629151d6879b2ba6c99aadb5a6c90aaede52d 100644 (file)
@@ -181,7 +181,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
                        } else {
                                sub->sub_io = kzalloc(sizeof(*sub->sub_io),
                                                      GFP_NOFS);
-                               if (sub->sub_io == NULL)
+                               if (!sub->sub_io)
                                        result = -ENOMEM;
                        }
                }
index 96c55acd52aed50a898e7006d8936a4595a7587d..cd6ed580c48ba342c48cc061272db53194d2d0c0 100644 (file)
@@ -976,7 +976,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
                src_oa->o_flags & OBD_FL_RECREATE_OBJS);
 
        obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS);
-       if (obj_mdp == NULL)
+       if (!obj_mdp)
                return -ENOMEM;
 
        ost_idx = src_oa->o_nlink;
index 1e4d3fbee323b6f4bed59947eae8506c9889e3be..c59b1402616e23e7c6e8521c1d1414149608924c 100644 (file)
@@ -431,7 +431,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
                return -ENAMETOOLONG;
 
        new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
-       if (new_pool == NULL)
+       if (!new_pool)
                return -ENOMEM;
 
        strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
index f4de8b84c5c25188503c2672b3818a474ad0db9c..416e42ed779252314820661f908bfa244a351259 100644 (file)
@@ -275,7 +275,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -301,7 +301,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -358,7 +358,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -384,7 +384,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -477,7 +477,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -500,7 +500,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
@@ -704,7 +704,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
        int rc = 0, i;
 
        set = kzalloc(sizeof(*set), GFP_NOFS);
-       if (set == NULL)
+       if (!set)
                return -ENOMEM;
        lov_init_set(set);
 
@@ -730,14 +730,14 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
                }
 
                req = kzalloc(sizeof(*req), GFP_NOFS);
-               if (req == NULL) {
+               if (!req) {
                        rc = -ENOMEM;
                        goto out_set;
                }
 
                req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs),
                                             GFP_NOFS);
-               if (req->rq_oi.oi_osfs == NULL) {
+               if (!req->rq_oi.oi_osfs) {
                        kfree(req);
                        rc = -ENOMEM;
                        goto out_set;