Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932700AbbFTRKd (ORCPT ); Sat, 20 Jun 2015 13:10:33 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:28576 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbbFTRJC (ORCPT ); Sat, 20 Jun 2015 13:09:02 -0400 X-IronPort-AV: E=Sophos;i="5.13,649,1427752800"; d="scan'208";a="137164044" 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 11/12] staging: lustre: osc: Use !x to check for kzalloc failure Date: Sat, 20 Jun 2015 18:59:09 +0200 Message-Id: <1434819550-3193-12-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: 1659 Lines: 62 !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/osc/osc_dev.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff -u -p a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -119,7 +119,7 @@ static int osc_packmd(struct obd_export if (*lmmp == NULL) { *lmmp = kzalloc(lmm_size, GFP_NOFS); - if (*lmmp == NULL) + if (!*lmmp) return -ENOMEM; } @@ -1909,7 +1909,7 @@ int osc_build_rpc(const struct lu_env *e mpflag = cfs_memory_pressure_get_and_set(); crattr = kzalloc(sizeof(*crattr), GFP_NOFS); - if (crattr == NULL) { + if (!crattr) { rc = -ENOMEM; goto out; } diff -u -p a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c --- a/drivers/staging/lustre/lustre/osc/osc_dev.c +++ b/drivers/staging/lustre/lustre/osc/osc_dev.c @@ -218,7 +218,7 @@ static struct lu_device *osc_device_allo int rc; od = kzalloc(sizeof(*od), GFP_NOFS); - if (od == NULL) + if (!od) return ERR_PTR(-ENOMEM); cl_device_init(&od->od_cl, t); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/