From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751737Ab1AZF7r (ORCPT ); Wed, 26 Jan 2011 00:59:47 -0500 Received: from mgw2.diku.dk ([130.225.96.92]:33906 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809Ab1AZF7p (ORCPT ); Wed, 26 Jan 2011 00:59:45 -0500 Date: Wed, 26 Jan 2011 06:59:39 +0100 (CET) From: Julia Lawall To: Peter =?iso-8859-1?q?H=FCwe?= 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 Subject: Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer as NULL pointer In-Reply-To: <201101252354.31217.PeterHuewe@gmx.de> Message-ID: References: <1295988851-23561-1-git-send-email-peterhuewe@gmx.de> <201101252354.31217.PeterHuewe@gmx.de> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="-511516320-865825280-1296021280=:18314" Content-ID: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---511516320-865825280-1296021280=:18314 Content-Type: TEXT/PLAIN; CHARSET=iso-8859-1 Content-Transfer-Encoding: 8BIT Content-ID: On Tue, 25 Jan 2011, Peter Hüwe wrote: > 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? No. > Or only for the kmalloc family? > > Do you remember the reason why !x should be preferred? Because it is a function call, and NULL represents failure of that function, not an actual NULL value. Here is an email that explains that: http://lkml.org/lkml/2007/7/27/103 Here is the beginning of the thread: http://lkml.org/lkml/2007/7/27/75 julia > 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 > > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > ---511516320-865825280-1296021280=:18314-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julia Lawall Date: Wed, 26 Jan 2011 05:59:39 +0000 Subject: Re: [PATCH] video/saa7164: Fix sparse warning: Using plain integer Message-Id: MIME-Version: 1 Content-Type: multipart/mixed; boundary="-511516320-865825280-1296021280=:18314" List-Id: References: <1295988851-23561-1-git-send-email-peterhuewe@gmx.de> <201101252354.31217.PeterHuewe@gmx.de> In-Reply-To: <201101252354.31217.PeterHuewe@gmx.de> To: Peter =?iso-8859-1?q?H=FCwe?= 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 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---511516320-865825280-1296021280=:18314 Content-Type: TEXT/PLAIN; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-ID: On Tue, 25 Jan 2011, Peter H=FCwe wrote: > 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. > >=20 > > I recall (a number of years ago) being told that for things like kmallo= c, > > the proper test was !x, not x =3D=3D NULL. > >=20 > > julia > >=20 >=20 >=20 > Hi Julia, >=20 > thanks for your input. > So do I understand you correctly if I say > if(!x) is better than if(x=3D=3DNULL) in any case? No. > Or only for the kmalloc family? >=20 > Do you remember the reason why !x should be preferred? Because it is a function call, and NULL represents failure of that=20 function, not an actual NULL value. Here is an email that explains that: http://lkml.org/lkml/2007/7/27/103 Here is the beginning of the thread: http://lkml.org/lkml/2007/7/27/75 julia > In Documentation/CodingStyle , Chapter 7: Centralized exiting of functio= ns=20 > there is a function fun with looks like this: > int fun(int a) > { > int result =3D 0; > char *buffer =3D kmalloc(SIZE); >=20 > if (buffer =3D=3D NULL) > return -ENOMEM; >=20 > if (condition1) { > while (loop1) { > ... > } > result =3D 1; > goto out; > } > ... > out: > kfree(buffer); > return result; > } >=20 >=20 > --> So if (buffer =3D=3D NULL) is in the official CodingStyle - maybe = we should=20 > add a paragraph there as well ;) >=20 >=20 > Don't get me wrong, I just want to learn ;) >=20 >=20 > Thanks, > Peter >=20 > -- > To unsubscribe from this list: send the line "unsubscribe kernel-janitors= " in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >=20 ---511516320-865825280-1296021280=:18314--