Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755534AbbFTRJl (ORCPT ); Sat, 20 Jun 2015 13:09:41 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:41406 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755154AbbFTRI5 (ORCPT ); Sat, 20 Jun 2015 13:08:57 -0400 X-IronPort-AV: E=Sophos;i="5.13,649,1427752800"; d="scan'208";a="137164037" From: Julia Lawall To: Oleg Drokin Cc: kernel-janitors@vger.kernel.org, Andreas Dilger , Greg Kroah-Hartman , HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/12] staging: lustre: ldlm: Use !x to check for kzalloc failure Date: Sat, 20 Jun 2015 18:59:02 +0200 Message-Id: <1434819550-3193-5-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1434819550-3193-1-git-send-email-Julia.Lawall@lip6.fr> References: <1434819550-3193-1-git-send-email-Julia.Lawall@lip6.fr> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2980 Lines: 102 !x is more normal for kzalloc failure in the kernel. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // @@ expression x; statement S1, S2; @@ x = kzalloc(...); if ( - x == NULL + !x ) S1 else S2 // Signed-off-by: Julia Lawall --- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 4 ++-- drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 8 ++++---- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -1422,7 +1422,7 @@ static int ldlm_pools_thread_start(void) return -EALREADY; ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS); - if (ldlm_pools_thread == NULL) + if (!ldlm_pools_thread) return -ENOMEM; init_completion(&ldlm_pools_comp); diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -225,7 +225,7 @@ static void ldlm_handle_cp_callback(stru void *lvb_data; lvb_data = kzalloc(lvb_len, GFP_NOFS); - if (lvb_data == NULL) { + if (!lvb_data) { LDLM_ERROR(lock, "No memory: %d.\n", lvb_len); rc = -ENOMEM; goto out; @@ -453,7 +453,7 @@ static int ldlm_bl_to_thread(struct ldlm struct ldlm_bl_work_item *blwi; blwi = kzalloc(sizeof(*blwi), GFP_NOFS); - if (blwi == NULL) + if (!blwi) return -ENOMEM; init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags); @@ -1053,7 +1053,7 @@ static int ldlm_setup(void) return -EALREADY; ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS); - if (ldlm_state == NULL) + if (!ldlm_state) return -ENOMEM; ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj); @@ -1123,7 +1123,7 @@ static int ldlm_setup(void) blp = kzalloc(sizeof(*blp), GFP_NOFS); - if (blp == NULL) { + if (!blp) { rc = -ENOMEM; goto out; } diff -u -p a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1528,7 +1528,7 @@ struct ldlm_lock *ldlm_lock_create(struc if (lvb_len) { lock->l_lvb_len = lvb_len; lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS); - if (lock->l_lvb_data == NULL) + if (!lock->l_lvb_data) goto out; } @@ -1813,7 +1813,7 @@ int ldlm_run_ast_work(struct ldlm_namesp return 0; arg = kzalloc(sizeof(*arg), GFP_NOFS); - if (arg == NULL) + if (!arg) return -ENOMEM; atomic_set(&arg->restart, 0); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/