Skip to content

Commit

Permalink
staging: lustre: lmv: Use !x to check for kzalloc failure
Browse files Browse the repository at this point in the history
!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 <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
JuliaLawall authored and gregkh committed Jul 14, 2015
1 parent 94e6776 commit 76e4290
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/staging/lustre/lustre/lmv/lmv_intent.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
}

op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) {
if (!op_data) {
rc = -ENOMEM;
goto out;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/staging/lustre/lustre/lmv/lmv_obd.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ static int lmv_fid2path(struct obd_export *exp, int len, void *karg, void *uarg)
if (remote_gf == NULL) {
remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
if (remote_gf == NULL) {
if (!remote_gf) {
rc = -ENOMEM;
goto out_fid2path;
}
Expand Down Expand Up @@ -1398,7 +1398,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
return rc;

temp = kzalloc(sizeof(*temp), GFP_NOFS);
if (temp == NULL)
if (!temp)
return -ENOMEM;

for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
Expand Down Expand Up @@ -1730,7 +1730,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
}

rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
if (rdata == NULL) {
if (!rdata) {
rc = -ENOMEM;
goto out;
}
Expand Down

0 comments on commit 76e4290

Please sign in to comment.