diff mbox

[25/30] dmaengine: s3c24xx: fix pointer cast warnings

Message ID 1473960849-23024-26-git-send-email-vinod.koul@intel.com (mailing list archive)
State Superseded
Headers show

Commit Message

Vinod Koul Sept. 15, 2016, 5:34 p.m. UTC
On some systems, pointer can be large than unsigned int, triggering warning
pointer-to-int-cast on conversion.

drivers/dma/s3c24xx-dma.c: In function 's3c24xx_dma_filter':
drivers/dma/s3c24xx-dma.c:1421:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]

Use a long value for type conversion.

Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
---
 drivers/dma/s3c24xx-dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Sept. 16, 2016, 12:51 p.m. UTC | #1
On 09/15/2016 07:34 PM, Vinod Koul wrote:
> On some systems, pointer can be large than unsigned int, triggering warning
> pointer-to-int-cast on conversion.
> 
> drivers/dma/s3c24xx-dma.c: In function 's3c24xx_dma_filter':
> drivers/dma/s3c24xx-dma.c:1421:24: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> Use a long value for type conversion.
> 
> Cc: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
> ---
>  drivers/dma/s3c24xx-dma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
> index b4a7041c4f81..2ec47478110b 100644
> --- a/drivers/dma/s3c24xx-dma.c
> +++ b/drivers/dma/s3c24xx-dma.c
> @@ -1418,7 +1418,7 @@ bool s3c24xx_dma_filter(struct dma_chan *chan, void *param)
>  
>  	s3cchan = to_s3c24xx_dma_chan(chan);
>  
> -	return s3cchan->id == (int)param;
> +	return s3cchan->id == (long)param;

The 'id' is an int so the cast might trick someone to think it is an
long. Also commit message suggests that the over-size cast issue is
fixed... but it is not. If the ID > INT_MAX then the problem will
silently occur. It does not look like a real issue but how about fixing
it completely by switching 'id' to long?

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Sept. 16, 2016, 2:05 p.m. UTC | #2
On Friday, September 16, 2016 2:51:22 PM CEST Krzysztof Kozlowski wrote:
> > diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
> > index b4a7041c4f81..2ec47478110b 100644
> > --- a/drivers/dma/s3c24xx-dma.c
> > +++ b/drivers/dma/s3c24xx-dma.c
> > @@ -1418,7 +1418,7 @@ bool s3c24xx_dma_filter(struct dma_chan *chan, void *param)
> >  
> >       s3cchan = to_s3c24xx_dma_chan(chan);
> >  
> > -     return s3cchan->id == (int)param;
> > +     return s3cchan->id == (long)param;
> 
> The 'id' is an int so the cast might trick someone to think it is an
> long. Also commit message suggests that the over-size cast issue is
> fixed... but it is not. If the ID > INT_MAX then the problem will
> silently occur. It does not look like a real issue but how about fixing
> it completely by switching 'id' to long?

This is about compile-testing on 64-bit architectures, where a cast from
pointer to 'int' causes a warning. I think the intention would be clearer
if using

	return s3cchan->id == (uintptr_t)param;

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Krzysztof Kozlowski Sept. 17, 2016, 6:49 p.m. UTC | #3
On Fri, Sep 16, 2016 at 04:05:22PM +0200, Arnd Bergmann wrote:
> On Friday, September 16, 2016 2:51:22 PM CEST Krzysztof Kozlowski wrote:
> > > diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
> > > index b4a7041c4f81..2ec47478110b 100644
> > > --- a/drivers/dma/s3c24xx-dma.c
> > > +++ b/drivers/dma/s3c24xx-dma.c
> > > @@ -1418,7 +1418,7 @@ bool s3c24xx_dma_filter(struct dma_chan *chan, void *param)
> > >  
> > >       s3cchan = to_s3c24xx_dma_chan(chan);
> > >  
> > > -     return s3cchan->id == (int)param;
> > > +     return s3cchan->id == (long)param;
> > 
> > The 'id' is an int so the cast might trick someone to think it is an
> > long. Also commit message suggests that the over-size cast issue is
> > fixed... but it is not. If the ID > INT_MAX then the problem will
> > silently occur. It does not look like a real issue but how about fixing
> > it completely by switching 'id' to long?
> 
> This is about compile-testing on 64-bit architectures, where a cast from
> pointer to 'int' causes a warning. I think the intention would be clearer
> if using
> 
> 	return s3cchan->id == (uintptr_t)param;

I like it. Fixes the warning and the cast is obvious.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe dmaengine" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vinod Koul Sept. 20, 2016, 3:28 a.m. UTC | #4
On Sat, Sep 17, 2016 at 08:49:51PM +0200, Krzysztof Kozlowski wrote:
> On Fri, Sep 16, 2016 at 04:05:22PM +0200, Arnd Bergmann wrote:
> > On Friday, September 16, 2016 2:51:22 PM CEST Krzysztof Kozlowski wrote:
> > > > diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
> > > > index b4a7041c4f81..2ec47478110b 100644
> > > > --- a/drivers/dma/s3c24xx-dma.c
> > > > +++ b/drivers/dma/s3c24xx-dma.c
> > > > @@ -1418,7 +1418,7 @@ bool s3c24xx_dma_filter(struct dma_chan *chan, void *param)
> > > >  
> > > >       s3cchan = to_s3c24xx_dma_chan(chan);
> > > >  
> > > > -     return s3cchan->id == (int)param;
> > > > +     return s3cchan->id == (long)param;
> > > 
> > > The 'id' is an int so the cast might trick someone to think it is an
> > > long. Also commit message suggests that the over-size cast issue is
> > > fixed... but it is not. If the ID > INT_MAX then the problem will
> > > silently occur. It does not look like a real issue but how about fixing
> > > it completely by switching 'id' to long?
> > 
> > This is about compile-testing on 64-bit architectures, where a cast from
> > pointer to 'int' causes a warning. I think the intention would be clearer
> > if using
> > 
> > 	return s3cchan->id == (uintptr_t)param;
> 
> I like it. Fixes the warning and the cast is obvious.

Its better one, so I am folding it up..
diff mbox

Patch

diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c
index b4a7041c4f81..2ec47478110b 100644
--- a/drivers/dma/s3c24xx-dma.c
+++ b/drivers/dma/s3c24xx-dma.c
@@ -1418,7 +1418,7 @@  bool s3c24xx_dma_filter(struct dma_chan *chan, void *param)
 
 	s3cchan = to_s3c24xx_dma_chan(chan);
 
-	return s3cchan->id == (int)param;
+	return s3cchan->id == (long)param;
 }
 EXPORT_SYMBOL(s3c24xx_dma_filter);