Skip to contentSkip to conversation

pata_ipx4xx_cf: Fix unsigned comparison with less than zero

PATCH Applied angkery 3 participants 6 messages Apr 9, 2021 – Apr 10, 2021 libata

lore
Share & tools
lore

angkery

author
#0 lore raw

PATCH 1/1 pata_ipx4xx_cf: Fix unsigned comparison with less than zero

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

---
 drivers/ata/pata_ixp4xx_cf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ixp4xx_cf.c +1 -1
index abc0e87..43215a4 100644
@@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,
 
 static int ixp4xx_pata_probe(struct platform_device *pdev)
 {
-	unsigned int irq;
 	struct resource *cs0, *cs1;
 	struct ata_host *host;
 	struct ata_port *ap;
 	struct ixp4xx_pata_data *data = dev_get_platdata(&pdev->dev);
 	int ret;
+	int irq;
 
 	cs0 = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	cs1 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
Signature · 1 line
1.9.1
Applied
#1 lore raw
Quoted 9 lines · angkery

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

Applied, thanks.

Signature · 1 line
Jens Axboe
#2 lore raw
In reply to angkery
Quoted 9 lines · angkery

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

I'd understand < 0... but > 0? What tool warned about this issue?

Quoted 10 lines
---
 drivers/ata/pata_ixp4xx_cf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ixp4xx_cf.c +0 -0
index abc0e87..43215a4 100644

drivers/ata/pata_ixp4xx_cf.c static void ixp4xx_setup_port(struct ata_port *ap, · line 138

Quoted 4 lines
drivers/ata/pata_ixp4xx_cf.c +0 -1
@@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,
 
 static int ixp4xx_pata_probe(struct platform_device *pdev)
 {
-	unsigned int irq;

Oops, not sure how I missed that. :-/
Thanks for fixing my overlook. :-)

[...]

MBR, Sergei

Reviewed-by
#3 lore raw
Quoted 23 lines · Sergei Shtylyov
Quoted 9 lines

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

I'd understand < 0... but > 0? What tool warned about this issue?

Quoted 11 lines
---
 drivers/ata/pata_ixp4xx_cf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ata/pata_ixp4xx_cf.c +0 -0
index abc0e87..43215a4 100644
@@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct ata_port *ap,
 
Quoted 6 lines

drivers/ata/pata_ixp4xx_cf.c static void ixp4xx_setup_port(struct ata_port *ap, · line 138

Quoted 3 lines
drivers/ata/pata_ixp4xx_cf.c +0 -1
 static int ixp4xx_pata_probe(struct platform_device *pdev)
 {
-	unsigned int irq;

Oops, not sure how I missed that. :-/
Thanks for fixing my overlook. :-)

Forgot to add my

Quoted 1 line

[...]

MBR, Sergei

author
#4 lore raw
Quoted 41 lines · On Fri, 9 Apr 2021 20:02:56 +0300 Sergei Shtylyov <[email protected]>…
Quoted 19 lines · Sergei Shtylyov
Quoted 9 lines

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

I'd understand < 0... but > 0? What tool warned about this issue?

Quoted 7 lines

yes, by coccicheck, i will update commits information.

---
 drivers/ata/pata_ixp4xx_cf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/ata/pata_ixp4xx_cf.c static void ixp4xx_setup_port(struct · line 138

Quoted 9 lines
(quoted diff) +0 -0

b/drivers/ata/pata_ixp4xx_cf.c index abc0e87..43215a4 100644

drivers/ata/pata_ixp4xx_cf.c +0 -1
@@ -135,12 +135,12 @@ static void ixp4xx_setup_port(struct
 ata_port *ap, 
 static int ixp4xx_pata_probe(struct platform_device *pdev)
 {
-	unsigned int irq;  

Oops, not sure how I missed that. :-/
Thanks for fixing my overlook. :-)

Forgot to add my

Quoted 1 line

[...]

MBR, Sergei

#5 lore raw
Quoted 12 lines · angkery
Quoted 9 lines · On Fri, 9 Apr 2021 20:02:56 +0300 Sergei Shtylyov <[email protected]>…
Quoted 7 lines · Sergei Shtylyov
Quoted 7 lines

From: Junlin Yang <[email protected]>

The return from the call to platform_get_irq() is int, it can be a negative error code, however this is being assigned to an unsigned int variable 'irq', so making 'irq' an int, and change the position to keep the code format.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

./drivers/ata/pata_ixp4xx_cf.c:168:5-8:
WARNING: Unsigned expression compared with zero: irq > 0

I'd understand < 0... but > 0? What tool warned about this issue?

Quoted 1 line

yes, by coccicheck, i will update commits information.

Thanks!
Yet, looking at your subject, the above should read irq < 0, not > 0.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line