Commit 36a86fe6 authored by Julia Lawall's avatar Julia Lawall Committed by Greg Kroah-Hartman

staging: lustre: lov: Use !x to check for kzalloc failure

!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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 76e4290c
...@@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, ...@@ -478,7 +478,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
int rc; int rc;
ld = kzalloc(sizeof(*ld), GFP_NOFS); ld = kzalloc(sizeof(*ld), GFP_NOFS);
if (ld == NULL) if (!ld)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
cl_device_init(&ld->ld_cl, t); cl_device_init(&ld->ld_cl, t);
......
...@@ -181,7 +181,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio, ...@@ -181,7 +181,7 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
} else { } else {
sub->sub_io = kzalloc(sizeof(*sub->sub_io), sub->sub_io = kzalloc(sizeof(*sub->sub_io),
GFP_NOFS); GFP_NOFS);
if (sub->sub_io == NULL) if (!sub->sub_io)
result = -ENOMEM; result = -ENOMEM;
} }
} }
......
...@@ -976,7 +976,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa, ...@@ -976,7 +976,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
src_oa->o_flags & OBD_FL_RECREATE_OBJS); src_oa->o_flags & OBD_FL_RECREATE_OBJS);
obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS); obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS);
if (obj_mdp == NULL) if (!obj_mdp)
return -ENOMEM; return -ENOMEM;
ost_idx = src_oa->o_nlink; ost_idx = src_oa->o_nlink;
......
...@@ -431,7 +431,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) ...@@ -431,7 +431,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
return -ENAMETOOLONG; return -ENAMETOOLONG;
new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS); new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
if (new_pool == NULL) if (!new_pool)
return -ENOMEM; return -ENOMEM;
strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME); strncpy(new_pool->pool_name, poolname, LOV_MAXPOOLNAME);
......
...@@ -275,7 +275,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -275,7 +275,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
int rc = 0, i; int rc = 0, i;
set = kzalloc(sizeof(*set), GFP_NOFS); set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL) if (!set)
return -ENOMEM; return -ENOMEM;
lov_init_set(set); lov_init_set(set);
...@@ -301,7 +301,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -301,7 +301,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
} }
req = kzalloc(sizeof(*req), GFP_NOFS); req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) { if (!req) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_set; goto out_set;
} }
...@@ -358,7 +358,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -358,7 +358,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
int rc = 0, i; int rc = 0, i;
set = kzalloc(sizeof(*set), GFP_NOFS); set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL) if (!set)
return -ENOMEM; return -ENOMEM;
lov_init_set(set); lov_init_set(set);
...@@ -384,7 +384,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -384,7 +384,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
} }
req = kzalloc(sizeof(*req), GFP_NOFS); req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) { if (!req) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_set; goto out_set;
} }
...@@ -477,7 +477,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -477,7 +477,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
int rc = 0, i; int rc = 0, i;
set = kzalloc(sizeof(*set), GFP_NOFS); set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL) if (!set)
return -ENOMEM; return -ENOMEM;
lov_init_set(set); lov_init_set(set);
...@@ -500,7 +500,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo, ...@@ -500,7 +500,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
} }
req = kzalloc(sizeof(*req), GFP_NOFS); req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) { if (!req) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_set; goto out_set;
} }
...@@ -704,7 +704,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, ...@@ -704,7 +704,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
int rc = 0, i; int rc = 0, i;
set = kzalloc(sizeof(*set), GFP_NOFS); set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL) if (!set)
return -ENOMEM; return -ENOMEM;
lov_init_set(set); lov_init_set(set);
...@@ -730,14 +730,14 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo, ...@@ -730,14 +730,14 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
} }
req = kzalloc(sizeof(*req), GFP_NOFS); req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) { if (!req) {
rc = -ENOMEM; rc = -ENOMEM;
goto out_set; goto out_set;
} }
req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs), req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs),
GFP_NOFS); GFP_NOFS);
if (req->rq_oi.oi_osfs == NULL) { if (!req->rq_oi.oi_osfs) {
kfree(req); kfree(req);
rc = -ENOMEM; rc = -ENOMEM;
goto out_set; goto out_set;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment