diff mbox

[1/1] of: Fix null pointer related warnings in base.c file

Message ID 1338808505-2028-1-git-send-email-sachin.kamat@linaro.org
State Superseded
Headers show

Commit Message

Sachin Kamat June 4, 2012, 11:15 a.m. UTC
Fixes the following sparse warnings:
drivers/of/base.c:176:41: warning: Using plain integer as NULL pointer
drivers/of/base.c:178:37: warning: Using plain integer as NULL pointer
drivers/of/base.c:500:49: warning: Using plain integer as NULL pointer

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/of/base.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Comments

Rob Herring June 26, 2012, 10:33 p.m. UTC | #1
On 06/04/2012 06:15 AM, Sachin Kamat wrote:
> Fixes the following sparse warnings:
> drivers/of/base.c:176:41: warning: Using plain integer as NULL pointer
> drivers/of/base.c:178:37: warning: Using plain integer as NULL pointer
> drivers/of/base.c:500:49: warning: Using plain integer as NULL pointer
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>

Sorry for the delay.

> ---
>  drivers/of/base.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index d9bfd49..2031aa1 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -173,9 +173,9 @@ struct property *of_find_property(const struct device_node *np,
>  		return NULL;
>  
>  	read_lock(&devtree_lock);
> -	for (pp = np->properties; pp != 0; pp = pp->next) {
> +	for (pp = np->properties; pp != NULL; pp = pp->next) {

How about just "pp"

>  		if (of_prop_cmp(pp->name, name) == 0) {
> -			if (lenp != 0)
> +			if (lenp != NULL)

and "if (lenp)"

>  				*lenp = pp->length;
>  			break;
>  		}
> @@ -497,7 +497,7 @@ struct device_node *of_find_node_with_property(struct device_node *from,
>  	read_lock(&devtree_lock);
>  	np = from ? from->allnext : allnodes;
>  	for (; np; np = np->allnext) {
> -		for (pp = np->properties; pp != 0; pp = pp->next) {
> +		for (pp = np->properties; pp != NULL; pp = pp->next) {

ditto

Rob

>  			if (of_prop_cmp(pp->name, prop_name) == 0) {
>  				of_node_get(np);
>  				goto out;
Sachin Kamat June 27, 2012, 4:21 a.m. UTC | #2
Thanks for the review Rob.
I will update the patch as per your comments and re-post it.

On 27/06/2012, Rob Herring <robherring2@gmail.com> wrote:
> On 06/04/2012 06:15 AM, Sachin Kamat wrote:
>> Fixes the following sparse warnings:
>> drivers/of/base.c:176:41: warning: Using plain integer as NULL pointer
>> drivers/of/base.c:178:37: warning: Using plain integer as NULL pointer
>> drivers/of/base.c:500:49: warning: Using plain integer as NULL pointer
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>
> Sorry for the delay.
>
>> ---
>>  drivers/of/base.c |    6 +++---
>>  1 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index d9bfd49..2031aa1 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -173,9 +173,9 @@ struct property *of_find_property(const struct
>> device_node *np,
>>  		return NULL;
>>
>>  	read_lock(&devtree_lock);
>> -	for (pp = np->properties; pp != 0; pp = pp->next) {
>> +	for (pp = np->properties; pp != NULL; pp = pp->next) {
>
> How about just "pp"
>
>>  		if (of_prop_cmp(pp->name, name) == 0) {
>> -			if (lenp != 0)
>> +			if (lenp != NULL)
>
> and "if (lenp)"
>
>>  				*lenp = pp->length;
>>  			break;
>>  		}
>> @@ -497,7 +497,7 @@ struct device_node *of_find_node_with_property(struct
>> device_node *from,
>>  	read_lock(&devtree_lock);
>>  	np = from ? from->allnext : allnodes;
>>  	for (; np; np = np->allnext) {
>> -		for (pp = np->properties; pp != 0; pp = pp->next) {
>> +		for (pp = np->properties; pp != NULL; pp = pp->next) {
>
> ditto
>
> Rob
>
>>  			if (of_prop_cmp(pp->name, prop_name) == 0) {
>>  				of_node_get(np);
>>  				goto out;
>
diff mbox

Patch

diff --git a/drivers/of/base.c b/drivers/of/base.c
index d9bfd49..2031aa1 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -173,9 +173,9 @@  struct property *of_find_property(const struct device_node *np,
 		return NULL;
 
 	read_lock(&devtree_lock);
-	for (pp = np->properties; pp != 0; pp = pp->next) {
+	for (pp = np->properties; pp != NULL; pp = pp->next) {
 		if (of_prop_cmp(pp->name, name) == 0) {
-			if (lenp != 0)
+			if (lenp != NULL)
 				*lenp = pp->length;
 			break;
 		}
@@ -497,7 +497,7 @@  struct device_node *of_find_node_with_property(struct device_node *from,
 	read_lock(&devtree_lock);
 	np = from ? from->allnext : allnodes;
 	for (; np; np = np->allnext) {
-		for (pp = np->properties; pp != 0; pp = pp->next) {
+		for (pp = np->properties; pp != NULL; pp = pp->next) {
 			if (of_prop_cmp(pp->name, prop_name) == 0) {
 				of_node_get(np);
 				goto out;