Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754223AbdC1OE2 (ORCPT ); Tue, 28 Mar 2017 10:04:28 -0400 Received: from a3.inai.de ([88.198.180.161]:57876 "EHLO a3.inai.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753234AbdC1OEZ (ORCPT ); Tue, 28 Mar 2017 10:04:25 -0400 X-Greylist: delayed 571 seconds by postgrey-1.27 at vger.kernel.org; Tue, 28 Mar 2017 10:04:24 EDT Date: Tue, 28 Mar 2017 15:54:40 +0200 (CEST) From: Jan Engelhardt To: simran singhal cc: wensong@linux-vs.org, Simon Horman , Julian Anastasov , Pablo Neira Ayuso , Jozsef Kadlecsik , "David S. Miller" , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-kernel@vger.kernel.org, outreachy-kernel@googlegroups.com Subject: Re: [PATCH v2] netfilter: Clean up tests if NULL returned on failure In-Reply-To: <20170328131340.GA19688@singhal-Inspiron-5558> Message-ID: References: <20170328131340.GA19688@singhal-Inspiron-5558> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 643 Lines: 17 On Tuesday 2017-03-28 15:13, simran singhal wrote: >Some functions like kmalloc/kzalloc return NULL on failure. When NULL >represents failure, !x is commonly used. > >@@ -910,7 +910,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, > } > > dest = kzalloc(sizeof(struct ip_vs_dest), GFP_KERNEL); >- if (dest == NULL) >+ if (!dest) > return -ENOMEM; This kind of transformation however is not cleanup anymore, it's really bikeshedding and should be avoided. There are pro and cons for both variants, and there is not really an overwhelming number of arguments for either variant to justify the change.