public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix missing 'cnt' in ?: in dmatest
@ 2011-08-21  0:50 Dr. David Alan Gilbert
  2011-08-21  1:12 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2011-08-21  0:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: nicolas.ferre, dan.j.williams, akpm

Hi,
  On the latest tree my compiler has started giving the warning:

drivers/dma/dmatest.c:575:28: warning: the omitted middle operand in ?: will always be ?true?, suggest explicit middle operand [-Wparentheses]

The following patch fixes the missing middle clause with the same
fix that Nicolas Ferre used in the similar clauses.
(There seems to have been a race between him fixing that and
the extra clause going in a little later).

I don't actually know the dmatest code/structures, nor do I own
any hardware to test it on (assuming it needs a DMA engine);
 but this patch builds, the existing code is almost certainly
wrong and the fix is the same as the corresponding lines above it.

(WTH is x=y?:z legal C anyway?)

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

---
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 765f5ff..1b0ec9d 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -572,7 +572,7 @@ static int dmatest_add_channel(struct dma_chan *chan)
 	}
 	if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
 		cnt = dmatest_add_threads(dtc, DMA_PQ);
-		thread_count += cnt > 0 ?: 0;
+		thread_count += cnt > 0 ? cnt : 0;
 	}
 
 	pr_info("dmatest: Started %u threads using %s\n",

-- 
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\ gro.gilbert @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/

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

* Re: [PATCH] Fix missing 'cnt' in ?: in dmatest
  2011-08-21  0:50 [PATCH] Fix missing 'cnt' in ?: in dmatest Dr. David Alan Gilbert
@ 2011-08-21  1:12 ` Al Viro
  2011-08-25 22:55   ` Dan Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Al Viro @ 2011-08-21  1:12 UTC (permalink / raw)
  To: Dr. David Alan Gilbert; +Cc: linux-kernel, nicolas.ferre, dan.j.williams, akpm

On Sun, Aug 21, 2011 at 01:50:31AM +0100, Dr. David Alan Gilbert wrote:

> (WTH is x=y?:z legal C anyway?)

gccism.  It's not legal C; it's a gcc extension, and not a pretty one at
that.  It's almost definitely a bug in this case - what used to be in the
tree is equivalent to cnt > 0 ? cnt > 0 : 0, i.e. cnt > 0 ? 1 : 0, i.e.
cnt > 0.  AFAICS, after your patch it does make sense.

> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
> 
> ---
> diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
> index 765f5ff..1b0ec9d 100644
> --- a/drivers/dma/dmatest.c
> +++ b/drivers/dma/dmatest.c
> @@ -572,7 +572,7 @@ static int dmatest_add_channel(struct dma_chan *chan)
>  	}
>  	if (dma_has_cap(DMA_PQ, dma_dev->cap_mask)) {
>  		cnt = dmatest_add_threads(dtc, DMA_PQ);
> -		thread_count += cnt > 0 ?: 0;
> +		thread_count += cnt > 0 ? cnt : 0;
>  	}
>  
>  	pr_info("dmatest: Started %u threads using %s\n",
> 
> -- 
>  -----Open up your eyes, open up your mind, open up your code -------   
> / Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
> \ gro.gilbert @ treblig.org |                               | In Hex /
>  \ _________________________|_____ http://www.treblig.org   |_______/
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH] Fix missing 'cnt' in ?: in dmatest
  2011-08-21  1:12 ` Al Viro
@ 2011-08-25 22:55   ` Dan Williams
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Williams @ 2011-08-25 22:55 UTC (permalink / raw)
  To: Al Viro; +Cc: Dr. David Alan Gilbert, linux-kernel, nicolas.ferre, akpm

On Sat, Aug 20, 2011 at 6:12 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Sun, Aug 21, 2011 at 01:50:31AM +0100, Dr. David Alan Gilbert wrote:
>
>> (WTH is x=y?:z legal C anyway?)
>
> gccism.  It's not legal C; it's a gcc extension, and not a pretty one at
> that.  It's almost definitely a bug in this case - what used to be in the
> tree is equivalent to cnt > 0 ? cnt > 0 : 0, i.e. cnt > 0 ? 1 : 0, i.e.
> cnt > 0.  AFAICS, after your patch it does make sense.
>
>> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

Thanks, I'll take this through the async_tx.git tree.

--
Dan

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

end of thread, other threads:[~2011-08-25 22:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-21  0:50 [PATCH] Fix missing 'cnt' in ?: in dmatest Dr. David Alan Gilbert
2011-08-21  1:12 ` Al Viro
2011-08-25 22:55   ` Dan Williams

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