Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754986AbdC2JQE (ORCPT ); Wed, 29 Mar 2017 05:16:04 -0400 Received: from mail-vk0-f65.google.com ([209.85.213.65]:32910 "EHLO mail-vk0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753309AbdC2JP7 (ORCPT ); Wed, 29 Mar 2017 05:15:59 -0400 MIME-Version: 1.0 In-Reply-To: References: <20170328131340.GA19688@singhal-Inspiron-5558> From: SIMRAN SINGHAL Date: Wed, 29 Mar 2017 14:45:57 +0530 Message-ID: Subject: Re: [PATCH v2] netfilter: Clean up tests if NULL returned on failure To: Jan Engelhardt 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1575 Lines: 39 On Wed, Mar 29, 2017 at 2:19 PM, SIMRAN SINGHAL wrote: > On Wed, Mar 29, 2017 at 12:25 PM, Jan Engelhardt wrote: >> >> On Tuesday 2017-03-28 18:23, SIMRAN SINGHAL wrote: >>>On Tue, Mar 28, 2017 at 7:24 PM, Jan Engelhardt wrote: >>>> 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. >>> >>>Sorry, but I didn't get what you are trying to convey. And particularly pros and >>>cons of both variants. >> >> The ==NULL/!=NULL part sort of ensures that the left side is a pointer, which >> is lost when just using the variable and have it implicitly convert to bool. > > Thanks for the explaination!!!! > > But, according to me we should prefer != NULL over ==NULL according to > coding style. Sorry their is typing mistake in above. But, according to me we should prefer !var over ( var ==NULL ) according to the coding style