public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [2.6 patch] mtd/cmdlinepart.c: don't compare pointers with 0
@ 2008-04-14 14:20 Adrian Bunk
  2008-04-14 14:42 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Bunk @ 2008-04-14 14:20 UTC (permalink / raw)
  To: dwmw2; +Cc: linux-mtd, linux-kernel

Sparse spotted that 0 was compared to pointers.

While I was at it, I also moved the assignments out of the if's.

Signed-off-by: Adrian Bunk <bunk@kernel.org>

---

 drivers/mtd/cmdlinepart.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

32de76e83f37322dd85eaecf126e7b17327f606f diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
index b44292a..3e09043 100644
--- a/drivers/mtd/cmdlinepart.c
+++ b/drivers/mtd/cmdlinepart.c
@@ -119,7 +119,8 @@ static struct mtd_partition * newpart(char *s,
 		char *p;
 
 	    	name = ++s;
-		if ((p = strchr(name, delim)) == 0)
+		p = strchr(name, delim);
+		if (!p)
 		{
 			printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim);
 			return NULL;
@@ -159,9 +160,10 @@ static struct mtd_partition * newpart(char *s,
 			return NULL;
 		}
 		/* more partitions follow, parse them */
-		if ((parts = newpart(s + 1, &s, num_parts,
-		                     this_part + 1, &extra_mem, extra_mem_size)) == 0)
-		  return NULL;
+		parts = newpart(s + 1, &s, num_parts, this_part + 1,
+				&extra_mem, extra_mem_size);
+		if (!parts)
+			return NULL;
 	}
 	else
 	{	/* this is the last partition: allocate space for all */

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

* Re: [2.6 patch] mtd/cmdlinepart.c: don't compare pointers with 0
  2008-04-14 14:20 [2.6 patch] mtd/cmdlinepart.c: don't compare pointers with 0 Adrian Bunk
@ 2008-04-14 14:42 ` Sergei Shtylyov
  2008-04-14 16:10   ` Adrian Bunk
  0 siblings, 1 reply; 3+ messages in thread
From: Sergei Shtylyov @ 2008-04-14 14:42 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-mtd, dwmw2, linux-kernel

Hello.

Adrian Bunk wrote:

> Sparse spotted that 0 was compared to pointers.

> While I was at it, I also moved the assignments out of the if's.

> Signed-off-by: Adrian Bunk <bunk@kernel.org>

> 32de76e83f37322dd85eaecf126e7b17327f606f diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
> index b44292a..3e09043 100644
> --- a/drivers/mtd/cmdlinepart.c
> +++ b/drivers/mtd/cmdlinepart.c
> @@ -119,7 +119,8 @@ static struct mtd_partition * newpart(char *s,
>  		char *p;
>  
>  	    	name = ++s;
> -		if ((p = strchr(name, delim)) == 0)
> +		p = strchr(name, delim);
> +		if (!p)
>  		{

    Wouldn't it be nice to join the standalone brace to if () while it?

>  			printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim);
>  			return NULL;

WBR, Sergei

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

* Re: [2.6 patch] mtd/cmdlinepart.c: don't compare pointers with 0
  2008-04-14 14:42 ` Sergei Shtylyov
@ 2008-04-14 16:10   ` Adrian Bunk
  0 siblings, 0 replies; 3+ messages in thread
From: Adrian Bunk @ 2008-04-14 16:10 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: linux-mtd, dwmw2, linux-kernel

On Mon, Apr 14, 2008 at 06:42:11PM +0400, Sergei Shtylyov wrote:
> Hello.
>
> Adrian Bunk wrote:
>
>> Sparse spotted that 0 was compared to pointers.
>
>> While I was at it, I also moved the assignments out of the if's.
>
>> Signed-off-by: Adrian Bunk <bunk@kernel.org>
>
>> 32de76e83f37322dd85eaecf126e7b17327f606f diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c
>> index b44292a..3e09043 100644
>> --- a/drivers/mtd/cmdlinepart.c
>> +++ b/drivers/mtd/cmdlinepart.c
>> @@ -119,7 +119,8 @@ static struct mtd_partition * newpart(char *s,
>>  		char *p;
>>   	    	name = ++s;
>> -		if ((p = strchr(name, delim)) == 0)
>> +		p = strchr(name, delim);
>> +		if (!p)
>>  		{
>
>    Wouldn't it be nice to join the standalone brace to if () while it?

Most of the file is written like this, so there's no point in changing 
it only here...

>>  			printk(KERN_ERR ERRP "no closing %c found in partition name\n", delim);
>>  			return NULL;
>
> WBR, Sergei

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

end of thread, other threads:[~2008-04-14 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-14 14:20 [2.6 patch] mtd/cmdlinepart.c: don't compare pointers with 0 Adrian Bunk
2008-04-14 14:42 ` Sergei Shtylyov
2008-04-14 16:10   ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox