* [patch] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 12:26 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 12:26 UTC (permalink / raw)
To: Mark Brown
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
"xspi->irq" is unsigned int so it's never less than zero. I have added
a cast.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index fea815c..e5201fb 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -442,7 +442,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
xspi_init_hw(xspi);
xspi->irq = platform_get_irq(pdev, 0);
- if (xspi->irq < 0) {
+ if ((int)xspi->irq < 0) {
ret = xspi->irq;
goto put_master;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [patch] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 12:26 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 12:26 UTC (permalink / raw)
To: Mark Brown
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
"xspi->irq" is unsigned int so it's never less than zero. I have added
a cast.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index fea815c..e5201fb 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -442,7 +442,7 @@ static int xilinx_spi_probe(struct platform_device *pdev)
xspi_init_hw(xspi);
xspi->irq = platform_get_irq(pdev, 0);
- if (xspi->irq < 0) {
+ if ((int)xspi->irq < 0) {
ret = xspi->irq;
goto put_master;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
2013-07-17 12:26 ` Dan Carpenter
@ 2013-07-17 15:03 ` Stephen Warren
-1 siblings, 0 replies; 12+ messages in thread
From: Stephen Warren @ 2013-07-17 15:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mark Brown, Grant Likely, devicetree-discuss, kernel-janitors,
Rob Herring, linux-spi
On 07/17/2013 06:26 AM, Dan Carpenter wrote:
> "xspi->irq" is unsigned int so it's never less than zero. I have added
> a cast.
Um. Doesn't this just hide a warning, not solve the problem? If the
value can't be negative, so the if condition never fires, then the cast
won't change that...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 15:03 ` Stephen Warren
0 siblings, 0 replies; 12+ messages in thread
From: Stephen Warren @ 2013-07-17 15:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: Mark Brown, Grant Likely, devicetree-discuss, kernel-janitors,
Rob Herring, linux-spi
On 07/17/2013 06:26 AM, Dan Carpenter wrote:
> "xspi->irq" is unsigned int so it's never less than zero. I have added
> a cast.
Um. Doesn't this just hide a warning, not solve the problem? If the
value can't be negative, so the if condition never fires, then the cast
won't change that...
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
[not found] ` <20130717122638.GB4851-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
@ 2013-07-17 15:05 ` Mark Brown
0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-17 15:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
linux-spi-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1.1: Type: text/plain, Size: 203 bytes --]
On Wed, Jul 17, 2013 at 03:26:38PM +0300, Dan Carpenter wrote:
> "xspi->irq" is unsigned int so it's never less than zero. I have added
> a cast.
Why is this better than changing irq to a signed type?
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 192 bytes --]
_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 15:05 ` Mark Brown
0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-17 15:05 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
linux-spi-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 203 bytes --]
On Wed, Jul 17, 2013 at 03:26:38PM +0300, Dan Carpenter wrote:
> "xspi->irq" is unsigned int so it's never less than zero. I have added
> a cast.
Why is this better than changing irq to a signed type?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
2013-07-17 15:03 ` Stephen Warren
@ 2013-07-17 15:34 ` Dan Carpenter
-1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 15:34 UTC (permalink / raw)
To: Stephen Warren
Cc: Mark Brown, Grant Likely, devicetree-discuss, kernel-janitors,
Rob Herring, linux-spi
On Wed, Jul 17, 2013 at 09:03:53AM -0600, Stephen Warren wrote:
> On 07/17/2013 06:26 AM, Dan Carpenter wrote:
> > "xspi->irq" is unsigned int so it's never less than zero. I have added
> > a cast.
>
> Um. Doesn't this just hide a warning, not solve the problem? If the
> value can't be negative, so the if condition never fires, then the cast
> won't change that...
No. It fixes the problem but Mark is right that it's ugly. Sorry
for that. I will resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 15:34 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 15:34 UTC (permalink / raw)
To: Stephen Warren
Cc: Mark Brown, Grant Likely, devicetree-discuss, kernel-janitors,
Rob Herring, linux-spi
On Wed, Jul 17, 2013 at 09:03:53AM -0600, Stephen Warren wrote:
> On 07/17/2013 06:26 AM, Dan Carpenter wrote:
> > "xspi->irq" is unsigned int so it's never less than zero. I have added
> > a cast.
>
> Um. Doesn't this just hide a warning, not solve the problem? If the
> value can't be negative, so the if condition never fires, then the cast
> won't change that...
No. It fixes the problem but Mark is right that it's ugly. Sorry
for that. I will resend.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
* [patch v2] spi/xilinx: signedness issue checking platform_get_irq()
2013-07-17 15:05 ` Mark Brown
@ 2013-07-17 15:34 ` Dan Carpenter
-1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 15:34 UTC (permalink / raw)
To: Mark Brown
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
In xilinx_spi_probe() we use xspi->irq to store negative error codes so
it has to be signed. We weren't going to use the upper bit any way so
this is fine.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: The first version introduced an ugly cast. Sorry for that.
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index fea815c..0f4a093 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -82,7 +82,7 @@ struct xilinx_spi {
struct completion done;
void __iomem *regs; /* virt. address of the control registers */
- u32 irq;
+ int irq;
u8 *rx_ptr; /* pointer in the Tx buffer */
const u8 *tx_ptr; /* pointer in the Rx buffer */
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [patch v2] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 15:34 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2013-07-17 15:34 UTC (permalink / raw)
To: Mark Brown
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
In xilinx_spi_probe() we use xspi->irq to store negative error codes so
it has to be signed. We weren't going to use the upper bit any way so
this is fine.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: The first version introduced an ugly cast. Sorry for that.
diff --git a/drivers/spi/spi-xilinx.c b/drivers/spi/spi-xilinx.c
index fea815c..0f4a093 100644
--- a/drivers/spi/spi-xilinx.c
+++ b/drivers/spi/spi-xilinx.c
@@ -82,7 +82,7 @@ struct xilinx_spi {
struct completion done;
void __iomem *regs; /* virt. address of the control registers */
- u32 irq;
+ int irq;
u8 *rx_ptr; /* pointer in the Tx buffer */
const u8 *tx_ptr; /* pointer in the Rx buffer */
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [patch v2] spi/xilinx: signedness issue checking platform_get_irq()
2013-07-17 15:34 ` Dan Carpenter
@ 2013-07-17 17:20 ` Mark Brown
-1 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-17 17:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
On Wed, Jul 17, 2013 at 06:34:48PM +0300, Dan Carpenter wrote:
> In xilinx_spi_probe() we use xspi->irq to store negative error codes so
> it has to be signed. We weren't going to use the upper bit any way so
> this is fine.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [patch v2] spi/xilinx: signedness issue checking platform_get_irq()
@ 2013-07-17 17:20 ` Mark Brown
0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2013-07-17 17:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: Grant Likely, Rob Herring, linux-spi, devicetree-discuss,
kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 244 bytes --]
On Wed, Jul 17, 2013 at 06:34:48PM +0300, Dan Carpenter wrote:
> In xilinx_spi_probe() we use xspi->irq to store negative error codes so
> it has to be signed. We weren't going to use the upper bit any way so
> this is fine.
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2013-07-17 17:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-17 12:26 [patch] spi/xilinx: signedness issue checking platform_get_irq() Dan Carpenter
2013-07-17 12:26 ` Dan Carpenter
2013-07-17 15:03 ` Stephen Warren
2013-07-17 15:03 ` Stephen Warren
2013-07-17 15:34 ` Dan Carpenter
2013-07-17 15:34 ` Dan Carpenter
[not found] ` <20130717122638.GB4851-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2013-07-17 15:05 ` Mark Brown
2013-07-17 15:05 ` Mark Brown
2013-07-17 15:34 ` [patch v2] " Dan Carpenter
2013-07-17 15:34 ` Dan Carpenter
2013-07-17 17:20 ` Mark Brown
2013-07-17 17:20 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.