From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753632Ab1AYWyf (ORCPT ); Tue, 25 Jan 2011 17:54:35 -0500 Received: from mailout-de.gmx.net ([213.165.64.23]:51079 "HELO mailout-de.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751827Ab1AYWyd (ORCPT ); Tue, 25 Jan 2011 17:54:33 -0500 X-Authenticated: #12255092 X-Provags-ID: V01U2FsdGVkX1+AwM1+8qWAnDOKjF8yZQlqi3Q+yxAEtOO16cQhOS oSZkC+60GXaZ41 From: Peter =?iso-8859-1?q?H=FCwe?= To: Julia Lawall Subject: Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Date: Tue, 25 Jan 2011 23:54:30 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.37; KDE/4.4.5; x86_64; ; ) Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Steven Toth , Tejun Heo , Dan Carpenter References: <1295988851-23561-1-git-send-email-peterhuewe@gmx.de> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201101252354.31217.PeterHuewe@gmx.de> X-Y-GMX-Trusted: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall: > On Tue, 25 Jan 2011, Peter Huewe wrote: > > This patch fixes the warning "Using plain integer as NULL pointer", > > generated by sparse, by replacing the offending 0s with NULL. > > I recall (a number of years ago) being told that for things like kmalloc, > the proper test was !x, not x == NULL. > > julia > Hi Julia, thanks for your input. So do I understand you correctly if I say if(!x) is better than if(x==NULL) in any case? Or only for the kmalloc family? Do you remember the reason why !x should be preferred? In Documentation/CodingStyle , Chapter 7: Centralized exiting of functions there is a function fun with looks like this: int fun(int a) { int result = 0; char *buffer = kmalloc(SIZE); if (buffer == NULL) return -ENOMEM; if (condition1) { while (loop1) { ... } result = 1; goto out; } ... out: kfree(buffer); return result; } --> So if (buffer == NULL) is in the official CodingStyle - maybe we should add a paragraph there as well ;) Don't get me wrong, I just want to learn ;) Thanks, Peter From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter =?iso-8859-1?q?H=FCwe?= Date: Tue, 25 Jan 2011 22:54:30 +0000 Subject: Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer Message-Id: <201101252354.31217.PeterHuewe@gmx.de> List-Id: References: <1295988851-23561-1-git-send-email-peterhuewe@gmx.de> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Julia Lawall Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Steven Toth , Tejun Heo , Dan Carpenter Am Dienstag 25 Januar 2011, 23:20:44 schrieb Julia Lawall: > On Tue, 25 Jan 2011, Peter Huewe wrote: > > This patch fixes the warning "Using plain integer as NULL pointer", > > generated by sparse, by replacing the offending 0s with NULL. > > I recall (a number of years ago) being told that for things like kmalloc, > the proper test was !x, not x = NULL. > > julia > Hi Julia, thanks for your input. So do I understand you correctly if I say if(!x) is better than if(x=NULL) in any case? Or only for the kmalloc family? Do you remember the reason why !x should be preferred? In Documentation/CodingStyle , Chapter 7: Centralized exiting of functions there is a function fun with looks like this: int fun(int a) { int result = 0; char *buffer = kmalloc(SIZE); if (buffer = NULL) return -ENOMEM; if (condition1) { while (loop1) { ... } result = 1; goto out; } ... out: kfree(buffer); return result; } --> So if (buffer = NULL) is in the official CodingStyle - maybe we should add a paragraph there as well ;) Don't get me wrong, I just want to learn ;) Thanks, Peter