0 -> NULL, for arch/arm
Subsystems (5)
PATCH 2/68 0 -> NULL, for arch/arm
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
---
common/dmabounce.c | 2 +- mach-omap1/clock.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/common/dmabounce.c +1 -1
@@ -238,7 +238,7 @@ map_single(struct device *dev, void *ptrstruct 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 ;
arch/arm/mach-omap1/clock.c +1 -1
@@ -193,7 +193,7 @@ static int calc_dsor_exp(struct clk *clkreturn -EINVAL ; parent = clk->parent; -if (unlikely (parent =0 )) +if (unlikely (parent =NULL ))return -EIO ; realrate = parent->rate;
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 3 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =alloc_safe_buffer (device_info, ptr, size, dir); -if (buf =0 ) { +if (buf =NULL ) {
if (!buf)
surely...
Quoted 7 lines · Al Viro
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 3 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =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.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Quoted 7 lines · Al Viro
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 3 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =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
Quoted 11 lines · Jan Engelhardt
Quoted 7 lines · Al Viro
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 3 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =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.
Quoted 10 lines · Alexey Dobriyan
Quoted 9 lines · Jan Engelhardt
Quoted 7 lines · Al Viro
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 3 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =alloc_safe_buffer (device_info, ptr, size, dir); -if (buf =0 ) { +if (buf =NULL ) {if (!buf)surely...
Quoted 3 lines
Quoted 1 line
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
Quoted 3 lines · Jan Engelhardt
Quoted 1 line
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.
Quoted 12 lines · Jan Engelhardt
Quoted 9 lines · Al Viro
arch/arm/common/dmabounce.c map_single(struct device *dev, void *ptr · line 241
Quoted 4 lines · Yoann Padioleau
arch/arm/common/dmabounce.c +1
-1buf =alloc_safe_buffer (device_info, ptr, size, dir); -if (buf =0 ) { +if (buf =NULL ) {if (!buf)surely...
Quoted 2 lines
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