2006-08-19 19:13:59

by Eric Sesterhenn

[permalink] [raw]
Subject: [Patch] Signedness issue in drivers/scsi/ipr.c

hi,

gcc 4.1 with some extra warnings show the following:

drivers/scsi/ipr.c:6361: warning: comparison of unsigned expression < 0 is always false
drivers/scsi/ipr.c:6385: warning: comparison of unsigned expression < 0 is always false
drivers/scsi/ipr.c:6415: warning: comparison of unsigned expression < 0 is always false

The problem is that rc is of the type u32, which can never be smaller than zero,
therefore all three error handling checks get useless. This patch changes it to
a normal int, because all usages / all functions it get used with expect an int.

Signed-off-by: Eric Sesterhenn <[email protected]>

--- linux-2.6.18-rc4/drivers/scsi/ipr.c.orig 2006-08-19 21:10:18.000000000 +0200
+++ linux-2.6.18-rc4/drivers/scsi/ipr.c 2006-08-19 21:10:25.000000000 +0200
@@ -6324,7 +6324,7 @@ static int __devinit ipr_probe_ioa(struc
struct Scsi_Host *host;
unsigned long ipr_regs_pci;
void __iomem *ipr_regs;
- u32 rc = PCIBIOS_SUCCESSFUL;
+ int rc = PCIBIOS_SUCCESSFUL;
volatile u32 mask, uproc;

ENTER;



2006-08-20 17:59:10

by Alan

[permalink] [raw]
Subject: Re: [Patch] Signedness issue in drivers/scsi/ipr.c

Ar Sad, 2006-08-19 am 21:13 +0200, ysgrifennodd Eric Sesterhenn:
> hi,
>
> gcc 4.1 with some extra warnings show the following:
>
> drivers/scsi/ipr.c:6361: warning: comparison of unsigned expression < 0 is always false
> drivers/scsi/ipr.c:6385: warning: comparison of unsigned expression < 0 is always false
> drivers/scsi/ipr.c:6415: warning: comparison of unsigned expression < 0 is always false
>

Acked-by: Alan Cox <[email protected]>

2006-08-20 18:57:09

by Brian King

[permalink] [raw]
Subject: Re: [Patch] Signedness issue in drivers/scsi/ipr.c

Eric Sesterhenn wrote:
> hi,
>
> gcc 4.1 with some extra warnings show the following:
>
> drivers/scsi/ipr.c:6361: warning: comparison of unsigned expression < 0 is always false
> drivers/scsi/ipr.c:6385: warning: comparison of unsigned expression < 0 is always false
> drivers/scsi/ipr.c:6415: warning: comparison of unsigned expression < 0 is always false

Acked-by: Brian King <[email protected]>

>
> The problem is that rc is of the type u32, which can never be smaller than zero,
> therefore all three error handling checks get useless. This patch changes it to
> a normal int, because all usages / all functions it get used with expect an int.
>
> Signed-off-by: Eric Sesterhenn <[email protected]>
>
> --- linux-2.6.18-rc4/drivers/scsi/ipr.c.orig 2006-08-19 21:10:18.000000000 +0200
> +++ linux-2.6.18-rc4/drivers/scsi/ipr.c 2006-08-19 21:10:25.000000000 +0200
> @@ -6324,7 +6324,7 @@ static int __devinit ipr_probe_ioa(struc
> struct Scsi_Host *host;
> unsigned long ipr_regs_pci;
> void __iomem *ipr_regs;
> - u32 rc = PCIBIOS_SUCCESSFUL;
> + int rc = PCIBIOS_SUCCESSFUL;
> volatile u32 mask, uproc;
>
> ENTER;
>
>