Skip to contentSkip to conversation

Signedness issue in drivers/scsi/ipr.c

PATCH In review Eric Sesterhenn 3 participants 3 messages Aug 19, 2006 – Aug 20, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

drivers/scsi/ipr.c renamed from drivers/scsi/ipr.c.orig +1 -1
@@ -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;
Acked-by on v1 1/1
#1 lore raw

Ar Sad, 2006-08-19 am 21:13 +0200, ysgrifennodd Eric Sesterhenn:

Quoted 8 lines

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

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Eric Sesterhenn
Quoted 7 lines · 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

Quoted 20 lines

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.

drivers/scsi/ipr.c renamed from drivers/scsi/ipr.c.orig +1 -1
@@ -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;