public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging/comedi: Fix if(); by adding proper code
@ 2013-02-14 21:36 Peter Huewe
  2013-02-15  9:54 ` Ian Abbott
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Huewe @ 2013-02-14 21:36 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Mori Hess, Greg Kroah-Hartman, H Hartley Sweeten, Bill Pemberton,
	Peter Huewe, devel, linux-kernel

Smatch warns about:
staging/comedi/drivers/cb_pcidas64.c:3304 prep_ao_dma() warn: if();

So the check currently does nothing and could be removed, but the better
alternative is to activate the check again and return -1; if it
evaluates to true.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
 drivers/staging/comedi/drivers/cb_pcidas64.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index d33fc32..782498f 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -3301,7 +3301,8 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 	num_bytes = load_ao_dma_buffer(dev, cmd);
 	if (num_bytes == 0)
 		return -1;
-	if (num_bytes >= DMA_BUFFER_SIZE) ;
+	if (num_bytes >= DMA_BUFFER_SIZE)
+		return -1;
 	load_ao_dma(dev, cmd);
 
 	dma_start_sync(dev, 0);
-- 
1.7.8.6


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

* Re: [PATCH] staging/comedi: Fix if(); by adding proper code
  2013-02-14 21:36 [PATCH] staging/comedi: Fix if(); by adding proper code Peter Huewe
@ 2013-02-15  9:54 ` Ian Abbott
  2013-02-15 12:14   ` [PATCH v2] staging/comedi: Remove if(); statement without effect Peter Huewe
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Abbott @ 2013-02-15  9:54 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Ian Abbott, Mori Hess, Greg Kroah-Hartman, H Hartley Sweeten,
	Bill Pemberton, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org

On 2013-02-14 21:36, Peter Huewe wrote:
> Smatch warns about:
> staging/comedi/drivers/cb_pcidas64.c:3304 prep_ao_dma() warn: if();
>
> So the check currently does nothing and could be removed, but the better
> alternative is to activate the check again and return -1; if it
> evaluates to true.
>
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
>   drivers/staging/comedi/drivers/cb_pcidas64.c |    3 ++-
>   1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
> index d33fc32..782498f 100644
> --- a/drivers/staging/comedi/drivers/cb_pcidas64.c
> +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
> @@ -3301,7 +3301,8 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
>   	num_bytes = load_ao_dma_buffer(dev, cmd);
>   	if (num_bytes == 0)
>   		return -1;
> -	if (num_bytes >= DMA_BUFFER_SIZE) ;
> +	if (num_bytes >= DMA_BUFFER_SIZE)
> +		return -1;
>   	load_ao_dma(dev, cmd);
>
>   	dma_start_sync(dev, 0);

I think the test is wrong as load_ao_dma_buffer can legitimately return 
DMA_BUFFER_SIZE.  Probably best just to get rid of the test altogether.

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

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

* [PATCH v2] staging/comedi: Remove if(); statement without effect
  2013-02-15  9:54 ` Ian Abbott
@ 2013-02-15 12:14   ` Peter Huewe
  2013-02-15 16:23     ` Ian Abbott
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Huewe @ 2013-02-15 12:14 UTC (permalink / raw)
  To: Ian Abbott
  Cc: Mori Hess, Greg Kroah-Hartman, H Hartley Sweeten, Bill Pemberton,
	Peter Huewe, devel, linux-kernel

Smatch warns about:
staging/comedi/drivers/cb_pcidas64.c:3304 prep_ao_dma() warn: if();

So the check currently does nothing and can be removed, as indicated by
Ian.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
v1 was staging/comedi: Fix if(); by adding proper code
which was unfortunately wrong.

 drivers/staging/comedi/drivers/cb_pcidas64.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index d33fc32..9f3112c 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -3301,7 +3301,6 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
 	num_bytes = load_ao_dma_buffer(dev, cmd);
 	if (num_bytes == 0)
 		return -1;
-	if (num_bytes >= DMA_BUFFER_SIZE) ;
 	load_ao_dma(dev, cmd);
 
 	dma_start_sync(dev, 0);
-- 
1.7.8.6


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

* Re: [PATCH v2] staging/comedi: Remove if(); statement without effect
  2013-02-15 12:14   ` [PATCH v2] staging/comedi: Remove if(); statement without effect Peter Huewe
@ 2013-02-15 16:23     ` Ian Abbott
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Abbott @ 2013-02-15 16:23 UTC (permalink / raw)
  To: Peter Huewe
  Cc: Ian Abbott, Mori Hess, Greg Kroah-Hartman, H Hartley Sweeten,
	Bill Pemberton, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org

On 2013-02-15 12:14, Peter Huewe wrote:
> Smatch warns about:
> staging/comedi/drivers/cb_pcidas64.c:3304 prep_ao_dma() warn: if();
>
> So the check currently does nothing and can be removed, as indicated by
> Ian.
>
> Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
> ---
> v1 was staging/comedi: Fix if(); by adding proper code
> which was unfortunately wrong.
>
>   drivers/staging/comedi/drivers/cb_pcidas64.c |    1 -
>   1 files changed, 0 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
> index d33fc32..9f3112c 100644
> --- a/drivers/staging/comedi/drivers/cb_pcidas64.c
> +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
> @@ -3301,7 +3301,6 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
>   	num_bytes = load_ao_dma_buffer(dev, cmd);
>   	if (num_bytes == 0)
>   		return -1;
> -	if (num_bytes >= DMA_BUFFER_SIZE) ;
>   	load_ao_dma(dev, cmd);
>
>   	dma_start_sync(dev, 0);
>

I suppose I'd better sign it off since you mentioned me. ;)

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-

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

end of thread, other threads:[~2013-02-15 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-14 21:36 [PATCH] staging/comedi: Fix if(); by adding proper code Peter Huewe
2013-02-15  9:54 ` Ian Abbott
2013-02-15 12:14   ` [PATCH v2] staging/comedi: Remove if(); statement without effect Peter Huewe
2013-02-15 16:23     ` Ian Abbott

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