kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 02/68] 0 -> NULL, for arch/arm
@ 2007-07-27  9:44 Yoann Padioleau
  2007-07-27  9:59 ` Al Viro
  0 siblings, 1 reply; 8+ messages in thread
From: Yoann Padioleau @ 2007-07-27  9:44 UTC (permalink / raw)
  To: kernel-janitors; +Cc: rmk, akpm, linux-kernel


When comparing a pointer, it's clearer to compare it to NULL than to 0.

Here is an excerpt of the semantic patch: 

@@
expression *E;
@@

  E =
- 0
+ NULL

@@
expression *E;
@@

  E !- 0
+ NULL

Signed-off-by: Yoann Padioleau <padator@wanadoo.fr>
Cc: rmk@arm.linux.org.uk
Cc: akpm@linux-foundation.org
---

 common/dmabounce.c |    2 +-
 mach-omap1/clock.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index b36b1e8..74ff750 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -238,7 +238,7 @@ map_single(struct device *dev, void *ptr
 		struct safe_buffer *buf;
 
 		buf = alloc_safe_buffer(device_info, ptr, size, dir);
-		if (buf = 0) {
+		if (buf = NULL) {
 			dev_err(dev, "%s: unable to map unsafe buffer %p!\n",
 			       __func__, ptr);
 			return 0;
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index f625f6d..b7e1b22 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -193,7 +193,7 @@ static int calc_dsor_exp(struct clk *clk
 		return -EINVAL;
 
 	parent = clk->parent;
-	if (unlikely(parent = 0))
+	if (unlikely(parent = NULL))
 		return -EIO;
 
 	realrate = parent->rate;


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27  9:44 [PATCH 02/68] 0 -> NULL, for arch/arm Yoann Padioleau
@ 2007-07-27  9:59 ` Al Viro
  2007-07-27 10:18   ` Russell King
  2007-07-27 10:50   ` Jan Engelhardt
  0 siblings, 2 replies; 8+ messages in thread
From: Al Viro @ 2007-07-27  9:59 UTC (permalink / raw)
  To: Yoann Padioleau; +Cc: kernel-janitors, rmk, akpm, linux-kernel

On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
>  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
> -		if (buf = 0) {
> +		if (buf = NULL) {

		if (!buf)
surely...

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27  9:59 ` Al Viro
@ 2007-07-27 10:18   ` Russell King
  2007-07-27 10:50   ` Jan Engelhardt
  1 sibling, 0 replies; 8+ messages in thread
From: Russell King @ 2007-07-27 10:18 UTC (permalink / raw)
  To: Al Viro; +Cc: Yoann Padioleau, kernel-janitors, akpm, linux-kernel

On Fri, Jul 27, 2007 at 10:59:05AM +0100, Al Viro wrote:
> On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
> >  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
> > -		if (buf = 0) {
> > +		if (buf = NULL) {
> 
> 		if (!buf)
> surely...

Definitely the preferred form.

Yoann, please remember to CC folk.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27  9:59 ` Al Viro
  2007-07-27 10:18   ` Russell King
@ 2007-07-27 10:50   ` Jan Engelhardt
  2007-07-27 12:07     ` Alexey Dobriyan
  2007-07-31 12:19     ` Richard Knutsson
  1 sibling, 2 replies; 8+ messages in thread
From: Jan Engelhardt @ 2007-07-27 10:50 UTC (permalink / raw)
  To: Al Viro; +Cc: Yoann Padioleau, kernel-janitors, rmk, akpm, linux-kernel


On Jul 27 2007 10:59, Al Viro wrote:
>On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
>>  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
>> -		if (buf = 0) {
>> +		if (buf = NULL) {
>
>		if (!buf)
>surely...

Makes it look like it's used as a bool.


	Jan
-- 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27 10:50   ` Jan Engelhardt
@ 2007-07-27 12:07     ` Alexey Dobriyan
  2007-07-27 12:18       ` Jan Engelhardt
  2007-07-31 12:19     ` Richard Knutsson
  1 sibling, 1 reply; 8+ messages in thread
From: Alexey Dobriyan @ 2007-07-27 12:07 UTC (permalink / raw)
  To: Jan Engelhardt
  Cc: Al Viro, Yoann Padioleau, kernel-janitors, rmk, akpm,
	linux-kernel

On 7/27/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
>
> On Jul 27 2007 10:59, Al Viro wrote:
> >On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
> >>  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
> >> -		if (buf = 0) {
> >> +		if (buf = NULL) {
> >
> >		if (!buf)
> >surely...
>
> Makes it look like it's used as a bool.

bool variables are rarely named buf, so no.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27 12:07     ` Alexey Dobriyan
@ 2007-07-27 12:18       ` Jan Engelhardt
  2007-07-27 12:30         ` Al Viro
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Engelhardt @ 2007-07-27 12:18 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Al Viro, Yoann Padioleau, kernel-janitors, rmk, akpm,
	linux-kernel


On Jul 27 2007 16:07, Alexey Dobriyan wrote:
>On 7/27/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
>> On Jul 27 2007 10:59, Al Viro wrote:
>> >On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
>> >>  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
>> >> -		if (buf = 0) {
>> >> +		if (buf = NULL) {
>> >
>> >		if (!buf)
>> >surely...
>>
>> Makes it look like it's used as a bool.
>
>bool variables are rarely named buf, so no.

Whatever. Java is good in one point: the ! operator requires a bool.


	Jan
-- 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27 12:18       ` Jan Engelhardt
@ 2007-07-27 12:30         ` Al Viro
  0 siblings, 0 replies; 8+ messages in thread
From: Al Viro @ 2007-07-27 12:30 UTC (permalink / raw)
  To: Jan Engelhardt
  Cc: Alexey Dobriyan, Yoann Padioleau, kernel-janitors, rmk, akpm,
	linux-kernel

On Fri, Jul 27, 2007 at 02:18:59PM +0200, Jan Engelhardt wrote:
> >bool variables are rarely named buf, so no.
> 
> Whatever. Java is good in one point: the ! operator requires a bool.

Language and style advocacy -> that way.  Use of scalar types, including
pointers, in conditional contexts is both 100% legal and, what's more
important, idiomatic C.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 02/68] 0 -> NULL, for arch/arm
  2007-07-27 10:50   ` Jan Engelhardt
  2007-07-27 12:07     ` Alexey Dobriyan
@ 2007-07-31 12:19     ` Richard Knutsson
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Knutsson @ 2007-07-31 12:19 UTC (permalink / raw)
  To: Jan Engelhardt
  Cc: Al Viro, Yoann Padioleau, kernel-janitors, rmk, akpm,
	linux-kernel

Jan Engelhardt wrote:
> On Jul 27 2007 10:59, Al Viro wrote:
>   
>> On Fri, Jul 27, 2007 at 11:44:07AM +0200, Yoann Padioleau wrote:
>>     
>>>  		buf = alloc_safe_buffer(device_info, ptr, size, dir);
>>> -		if (buf = 0) {
>>> +		if (buf = NULL) {
>>>       
>> 		if (!buf)
>> surely...
>>     
>
> Makes it look like it's used as a bool.
>   
But the conditional checking for a pointer and a boolean is the same; 0 
= NULL = 'false' and the rest is valid/'true'. So IMHO it is a cleaner 
way to write it. But then again, some people like to abuse the '!' on 
"regular" variables.

Richard Knutsson



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-07-31 12:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-27  9:44 [PATCH 02/68] 0 -> NULL, for arch/arm Yoann Padioleau
2007-07-27  9:59 ` Al Viro
2007-07-27 10:18   ` Russell King
2007-07-27 10:50   ` Jan Engelhardt
2007-07-27 12:07     ` Alexey Dobriyan
2007-07-27 12:18       ` Jan Engelhardt
2007-07-27 12:30         ` Al Viro
2007-07-31 12:19     ` Richard Knutsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).