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

staging: lustre: obdecho: 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 485640b5
...@@ -480,11 +480,11 @@ static int echo_alloc_memmd(struct echo_device *ed, ...@@ -480,11 +480,11 @@ static int echo_alloc_memmd(struct echo_device *ed,
LASSERT(*lsmp == NULL); LASSERT(*lsmp == NULL);
*lsmp = kzalloc(lsm_size, GFP_NOFS); *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (*lsmp == NULL) if (!*lsmp)
return -ENOMEM; return -ENOMEM;
(*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS); (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS);
if ((*lsmp)->lsm_oinfo[0] == NULL) { if (!(*lsmp)->lsm_oinfo[0]) {
kfree(*lsmp); kfree(*lsmp);
return -ENOMEM; return -ENOMEM;
} }
...@@ -701,7 +701,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env, ...@@ -701,7 +701,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
int cleanup = 0; int cleanup = 0;
ed = kzalloc(sizeof(*ed), GFP_NOFS); ed = kzalloc(sizeof(*ed), GFP_NOFS);
if (ed == NULL) { if (!ed) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
...@@ -1878,7 +1878,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, ...@@ -1878,7 +1878,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
return rc; return rc;
env = kzalloc(sizeof(*env), GFP_NOFS); env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL) if (!env)
return -ENOMEM; return -ENOMEM;
rc = lu_env_init(env, LCT_DT_THREAD); rc = lu_env_init(env, LCT_DT_THREAD);
...@@ -2049,7 +2049,7 @@ static int echo_client_setup(const struct lu_env *env, ...@@ -2049,7 +2049,7 @@ static int echo_client_setup(const struct lu_env *env,
ec->ec_nstripes = 0; ec->ec_nstripes = 0;
ocd = kzalloc(sizeof(*ocd), GFP_NOFS); ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
if (ocd == NULL) { if (!ocd) {
CERROR("Can't alloc ocd connecting to %s\n", CERROR("Can't alloc ocd connecting to %s\n",
lustre_cfg_string(lcfg, 1)); lustre_cfg_string(lcfg, 1));
return -ENOMEM; return -ENOMEM;
......
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