Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1169387

[PATCH 02/12] staging: lustre: fld: Use !x to check for kzalloc failure

From Julia Lawall <Julia.Lawall@lip6.fr>
Newsgroups linux.kernel
Subject [PATCH 02/12] staging: lustre: fld: Use !x to check for kzalloc failure
Date 2015-06-20 19:10 +0200
Message-ID <pDurf-4pO-13@gated-at.bofh.it> (permalink)
References <pDurf-4pO-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


!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>

---
 drivers/staging/lustre/lustre/fld/fld_cache.c   |    2 +-
 drivers/staging/lustre/lustre/fld/fld_request.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff -u -p a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -222,7 +222,7 @@ int fld_client_add_target(struct lu_clie
 			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);
diff -u -p a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -70,7 +70,7 @@ struct fld_cache *fld_cache_init(const c
 	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);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/12] Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:10 +0200
  [PATCH 04/12] staging: lustre: ldlm: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:10 +0200
  [PATCH 02/12] staging: lustre: fld: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:10 +0200
  [PATCH 07/12] staging: lustre: mdc: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:10 +0200
  [PATCH 03/12] staging: lustre: lclient: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:10 +0200
  [PATCH 11/12] staging: lustre: osc: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 06/12] staging: lustre: lov: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 01/12] staging: lustre: fid: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 09/12] staging: lustre: obdclass: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
    Re: [PATCH 09/12] staging: lustre: obdclass: Use !x to check for  kzalloc failure walter harms <wharms@bfs.de> - 2015-06-21 12:10 +0200
      Re: [PATCH 09/12] staging: lustre: obdclass: Use !x to check for  kzalloc failure Julia Lawall <julia.lawall@lip6.fr> - 2015-06-21 12:30 +0200
  [PATCH 10/12] staging: lustre: obdecho: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 05/12] staging: lustre: lmv: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 12/12] staging: lustre: ptlrpc: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200
  [PATCH 08/12] staging: lustre: mgc: Use !x to check for kzalloc failure Julia Lawall <Julia.Lawall@lip6.fr> - 2015-06-20 19:20 +0200

csiph-web