Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754348AbbFWIZR (ORCPT ); Tue, 23 Jun 2015 04:25:17 -0400 Received: from mga03.intel.com ([134.134.136.65]:10597 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753313AbbFWIZI convert rfc822-to-8bit (ORCPT ); Tue, 23 Jun 2015 04:25:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,664,1427785200"; d="scan'208";a="732819414" From: "Dilger, Andreas" To: Julia Lawall , "Drokin, Oleg" CC: "kernel-janitors@vger.kernel.org" , "Greg Kroah-Hartman" , "lustre-devel@lists.lustre.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 01/12] staging: lustre: fid: Use !x to check for kzalloc failure Thread-Topic: [PATCH 01/12] staging: lustre: fid: Use !x to check for kzalloc failure Thread-Index: AQHQq3vKpmcbKfHvD0SmgV/T61ZZfZ26QJ6A Date: Tue, 23 Jun 2015 08:25:05 +0000 Message-ID: References: <1434819550-3193-1-git-send-email-Julia.Lawall@lip6.fr> <1434819550-3193-2-git-send-email-Julia.Lawall@lip6.fr> In-Reply-To: <1434819550-3193-2-git-send-email-Julia.Lawall@lip6.fr> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.255.24.177] Content-Type: text/plain; charset="us-ascii" Content-ID: <1325DE021D7730459802080D60D5132D@intel.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1727 Lines: 56 On 2015/06/20, 10:58 AM, "Julia Lawall" wrote: >!x is more normal for kzalloc failure in the kernel. While "!x" might be more normal for kzalloc(), I don't see that as an improvement over explicitly checking against NULL, which is what kzalloc() and other memory-allocating functions return on error. I've found in the past that developers can introduce bugs when they treat return values as boolean when they really aren't. I'd prefer that the code is kept with explicit comparisons against NULL, as it is today. Most of the cases that are now using "!x" are from your previous patches. Cheers, Andreas >Signed-off-by: Julia Lawall > >--- > drivers/staging/lustre/lustre/fid/fid_request.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff -u -p a/drivers/staging/lustre/lustre/fid/fid_request.c >b/drivers/staging/lustre/lustre/fid/fid_request.c >--- a/drivers/staging/lustre/lustre/fid/fid_request.c >+++ b/drivers/staging/lustre/lustre/fid/fid_request.c >@@ -498,11 +498,11 @@ int client_fid_init(struct obd_device *o > int rc; > > cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS); >- if (cli->cl_seq == NULL) >+ if (!cli->cl_seq) > return -ENOMEM; > > prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS); >- if (prefix == NULL) { >+ if (!prefix) { > rc = -ENOMEM; > goto out_free_seq; > } > > Cheers, Andreas -- Andreas Dilger Lustre Software Architect Intel High Performance Data Division -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/