Skip to content

Commit

Permalink
staging: lustre: fld: 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 6c7c655 commit 812f205
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/staging/lustre/lustre/fld/fld_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion drivers/staging/lustre/lustre/fld/fld_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 812f205

Please sign in to comment.