Skip to contentSkip to conversation

Signdness issue in drivers/scsi/osst.c

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Signdness issue in drivers/scsi/osst.c

Hi,

another signdness warning from gcc 4.1

drivers/scsi/osst.c:5154: warning: comparison of unsigned expression < 0 is always false

The problem is that blk is defined as unsigned, but all usages of it are normal int cases. osst_get_frame_position() and osst_get_sector() return ints and can return negative values. If blk stays an unsigned int, the error check is useless.

drivers/scsi/osst.c renamed from drivers/scsi/osst.c.orig +1 -2
@@ -4843,8 +4843,7 @@ static int os_scsi_tape_close(struct ino
 static int osst_ioctl(struct inode * inode,struct file * file,
 	 unsigned int cmd_in, unsigned long arg)
 {
-	int		      i, cmd_nr, cmd_type, retval = 0;
-	unsigned int	      blk;
+	int		      i, cmd_nr, cmd_type, blk, retval = 0;
 	struct st_modedef   * STm;
 	struct st_partstat  * STps;
 	struct osst_request * SRpnt = NULL;
Acked-by on v1 1/1
#1 lore raw

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

Quoted 10 lines

Hi,

another signdness warning from gcc 4.1

drivers/scsi/osst.c:5154: warning: comparison of unsigned expression < 0 is always false

The problem is that blk is defined as unsigned, but all usages of it are normal int cases. osst_get_frame_position() and osst_get_sector() return ints and can return negative values. If blk stays an unsigned int, the error check is useless.