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

staging: lustre: ldlm: 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 c38ce354
...@@ -1528,7 +1528,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, ...@@ -1528,7 +1528,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
if (lvb_len) { if (lvb_len) {
lock->l_lvb_len = lvb_len; lock->l_lvb_len = lvb_len;
lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS); lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lock->l_lvb_data == NULL) if (!lock->l_lvb_data)
goto out; goto out;
} }
...@@ -1813,7 +1813,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list, ...@@ -1813,7 +1813,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
return 0; return 0;
arg = kzalloc(sizeof(*arg), GFP_NOFS); arg = kzalloc(sizeof(*arg), GFP_NOFS);
if (arg == NULL) if (!arg)
return -ENOMEM; return -ENOMEM;
atomic_set(&arg->restart, 0); atomic_set(&arg->restart, 0);
......
...@@ -225,7 +225,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, ...@@ -225,7 +225,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
void *lvb_data; void *lvb_data;
lvb_data = kzalloc(lvb_len, GFP_NOFS); lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lvb_data == NULL) { if (!lvb_data) {
LDLM_ERROR(lock, "No memory: %d.\n", lvb_len); LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
...@@ -453,7 +453,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns, ...@@ -453,7 +453,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
struct ldlm_bl_work_item *blwi; struct ldlm_bl_work_item *blwi;
blwi = kzalloc(sizeof(*blwi), GFP_NOFS); blwi = kzalloc(sizeof(*blwi), GFP_NOFS);
if (blwi == NULL) if (!blwi)
return -ENOMEM; return -ENOMEM;
init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags);
...@@ -1053,7 +1053,7 @@ static int ldlm_setup(void) ...@@ -1053,7 +1053,7 @@ static int ldlm_setup(void)
return -EALREADY; return -EALREADY;
ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS); ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS);
if (ldlm_state == NULL) if (!ldlm_state)
return -ENOMEM; return -ENOMEM;
ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj);
...@@ -1123,7 +1123,7 @@ static int ldlm_setup(void) ...@@ -1123,7 +1123,7 @@ static int ldlm_setup(void)
blp = kzalloc(sizeof(*blp), GFP_NOFS); blp = kzalloc(sizeof(*blp), GFP_NOFS);
if (blp == NULL) { if (!blp) {
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
......
...@@ -1422,7 +1422,7 @@ static int ldlm_pools_thread_start(void) ...@@ -1422,7 +1422,7 @@ static int ldlm_pools_thread_start(void)
return -EALREADY; return -EALREADY;
ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS); ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
if (ldlm_pools_thread == NULL) if (!ldlm_pools_thread)
return -ENOMEM; return -ENOMEM;
init_completion(&ldlm_pools_comp); init_completion(&ldlm_pools_comp);
......
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