Skip to contentSkip to conversation

drivers/scsi/device_handler/scsi_dh_emc.c: suppress warning

PATCH In review [email protected] 3 participants 4 messages Sep 22, 2008 – Oct 14, 2008 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 17/17 drivers/scsi/device_handler/scsi_dh_emc.c: suppress warning

From: Andrew Morton <[email protected]>

s390:

drivers/scsi/device_handler/scsi_dh_emc.c: In function 'parse_sp_info_reply':
drivers/scsi/device_handler/scsi_dh_emc.c:179: warning: comparison is always false due to limited range of data type

because chars are unsigned, I assume.

Cc Hannes Reinecke <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc James Bottomley <[email protected]>

---

 drivers/scsi/device_handler/scsi_dh_emc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/device_handler/scsi_dh_emc.c renamed from drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning +1 -1
diff -puN drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning drivers/scsi/device_handler/scsi_dh_emc.c
@@ -176,7 +176,7 @@ static int parse_sp_info_reply(struct sc
 		err = SCSI_DH_DEV_TEMP_BUSY;
 		goto out;
 	}
-	if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
+	if (csdev->buffer[4] & ~3) {
 		/* Invalid buffer format */
 		sdev_printk(KERN_NOTICE, sdev,
 			    "%s: invalid VPD page 0xC0 format\n",

_

maintainer
#1 lore raw
Quoted 8 lines · On Mon, 2008-09-22 at 14:56 -0700, [email protected] wrote:

From: Andrew Morton <[email protected]>

s390:

drivers/scsi/device_handler/scsi_dh_emc.c: In function 'parse_sp_info_reply':
drivers/scsi/device_handler/scsi_dh_emc.c:179: warning: comparison is always false due to limited range of data type

because chars are unsigned, I assume.

Actually, no, they're architecture implementation defined (another cockup of the C standard) ... which must be why we don't see this on any of the other architectures I compile on.

Quoted 13 lines
Cc Hannes Reinecke <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc James Bottomley <[email protected]>

---

 drivers/scsi/device_handler/scsi_dh_emc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning drivers/scsi/device_handler/scsi_dh_emc.c

drivers/scsi/device_handler/scsi_dh_emc.c static int parse_sp_info_reply(struct sc · line 179

Quoted 5 lines
drivers/scsi/device_handler/scsi_dh_emc.c renamed from drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning +1 -1
@@ -176,7 +176,7 @@ static int parse_sp_info_reply(struct sc
 		err = SCSI_DH_DEV_TEMP_BUSY;
 		goto out;
 	}
-	if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
+	if (csdev->buffer[4] & ~3) {

I'm afraid this isn't quite correct: ~3 will pass if csdev->buffer[4] == 3 which is beyond the range of the original comparison.

How about this: it doesn't depend on the architecture to define the signedness and it covers the original range?

James

---

drivers/scsi/device_handler/scsi_dh_emc.c +2 -2
index ef693e8..a4055c4 100644
@@ -84,7 +84,7 @@ struct clariion_dh_data {
 	/*
 	 * I/O buffer for both MODE_SELECT and INQUIRY commands.
 	 */
-	char buffer[CLARIION_BUFFER_SIZE];
+	unsigned char buffer[CLARIION_BUFFER_SIZE];
 	/*
 	 * SCSI sense buffer for commands -- assumes serial issuance
 	 * and completion sequence of all commands for same multipath.
@@ -176,7 +176,7 @@ static int parse_sp_info_reply(struct scsi_device *sdev,
 		err = SCSI_DH_DEV_TEMP_BUSY;
 		goto out;
 	}
-	if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
+	if (csdev->buffer[4] > 2) {
 		/* Invalid buffer format */
 		sdev_printk(KERN_NOTICE, sdev,
 			    "%s: invalid VPD page 0xC0 format\n",
#2 lore raw
Quoted 5 lines · On Tue, 23 Sep 2008 07:58:59 -0700 James Bottomley…
Quoted 4 lines · On Mon, 2008-09-22 at 14:56 -0700, [email protected] wrote:

From: Andrew Morton <[email protected]>

s390:

Quoted 8 lines
Quoted 4 lines

drivers/scsi/device_handler/scsi_dh_emc.c: In function 'parse_sp_info_reply':
drivers/scsi/device_handler/scsi_dh_emc.c:179: warning: comparison is always false due to limited range of data type

because chars are unsigned, I assume.

Actually, no, they're architecture implementation defined (another cockup of the C standard) ... which must be why we don't see this on any of the other architectures I compile on.

that's what I said ;)

Quoted 44 lines
Quoted 13 lines
Cc Hannes Reinecke <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc James Bottomley <[email protected]>

---

 drivers/scsi/device_handler/scsi_dh_emc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning drivers/scsi/device_handler/scsi_dh_emc.c

drivers/scsi/device_handler/scsi_dh_emc.c static int parse_sp_info_reply(struct sc · line 179

Quoted 5 lines
drivers/scsi/device_handler/scsi_dh_emc.c renamed from drivers/scsi/device_handler/scsi_dh_emc.c~drivers-scsi-device_handler-scsi_dh_emcc-suppress-warning +1 -1
@@ -176,7 +176,7 @@ static int parse_sp_info_reply(struct sc
 		err = SCSI_DH_DEV_TEMP_BUSY;
 		goto out;
 	}
-	if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
+	if (csdev->buffer[4] & ~3) {

I'm afraid this isn't quite correct: ~3 will pass if csdev->buffer[4] == 3 which is beyond the range of the original comparison.

How about this: it doesn't depend on the architecture to define the signedness and it covers the original range?

James

---

drivers/scsi/device_handler/scsi_dh_emc.c +1 -1
index ef693e8..a4055c4 100644
@@ -84,7 +84,7 @@ struct clariion_dh_data {
 	/*
 	 * I/O buffer for both MODE_SELECT and INQUIRY commands.
 	 */
-	char buffer[CLARIION_BUFFER_SIZE];
+	unsigned char buffer[CLARIION_BUFFER_SIZE];
 	/*
 	 * SCSI sense buffer for commands -- assumes serial issuance
 	 * and completion sequence of all commands for same multipath.

drivers/scsi/device_handler/scsi_dh_emc.c static int parse_sp_info_reply(struct scsi_device *sdev, · line 182

Quoted 8 lines
drivers/scsi/device_handler/scsi_dh_emc.c +1 -1
@@ -176,7 +176,7 @@ static int parse_sp_info_reply(struct scsi_device *sdev,
 		err = SCSI_DH_DEV_TEMP_BUSY;
 		goto out;
 	}
-	if (csdev->buffer[4] < 0 || csdev->buffer[4] > 2) {
+	if (csdev->buffer[4] > 2) {
 		/* Invalid buffer format */
 		sdev_printk(KERN_NOTICE, sdev,
 			    "%s: invalid VPD page 0xC0 format\n",

looks good to me.

Acked-by on v1 17/17
#3 lore raw
In reply to [email protected]

Hi Andrew,

Quoted 7 lines · [email protected] wrote:

From: Andrew Morton <[email protected]>

s390:

drivers/scsi/device_handler/scsi_dh_emc.c: In function 'parse_sp_info_reply':
drivers/scsi/device_handler/scsi_dh_emc.c:179: warning: comparison is always false due to limited range of data type

Quoted 6 lines

because chars are unsigned, I assume.

Cc Hannes Reinecke <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc James Bottomley <[email protected]>
Signature · 8 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html