Skip to contentSkip to conversation

Fix the comparison with sizeof()

PATCH In review Takashi Iwai 2 participants 2 messages Feb 14, 2006 – Feb 15, 2006

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

PATCH 1/1 Fix the comparison with sizeof()

Fix the comparison with sizeof() in min() macro.

---

drivers/scsi/aacraid/aachba.c +2 -2
index 7139659..6be4fb3 100644
@@ -1597,13 +1597,13 @@ int aac_scsi_cmd(struct scsi_cmnd * scsi
 		cp[11] = 0;
 		cp[12] = 0;
 		aac_internal_transfer(scsicmd, cp, 0,
-		  min((unsigned int)scsicmd->cmnd[13], sizeof(cp)));
+		  min((size_t)scsicmd->cmnd[13], sizeof(cp)));
 		if (sizeof(cp) < scsicmd->cmnd[13]) {
 			unsigned int len, offset = sizeof(cp);
 
 			memset(cp, 0, offset);
 			do {
-				len = min(scsicmd->cmnd[13]-offset, sizeof(cp));
+				len = min((size_t)(scsicmd->cmnd[13]-offset), sizeof(cp));
 				aac_internal_transfer(scsicmd, cp, offset, len);
 			} while ((offset += len) < scsicmd->cmnd[13]);
 		}
#1 lore raw
Quoted 3 lines · Takashi Iwai

- min((unsigned int)scsicmd->cmnd[13], sizeof(cp)));
+ min((size_t)scsicmd->cmnd[13], sizeof(cp)));

Note that this can also be done with the min_t() macro, although I can't immediately think of a reason why min_t() is any better..