Skip to contentSkip to conversation

usb: gadget: Remove the LUN checks which are always true

PATCH RESEND New Maxin B John 1 participant 1 message May 8, 2011 USB

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 usb: gadget: Remove the LUN checks which are always true

Comparing an unsigned integer with greater than or equal to zero is always true. So, it is safe to remove similar checks from 'f_mass_storage.c' and 'file_storage.c'

---

drivers/usb/gadget/f_mass_storage.c +1 -1
index 6d8e533..cade79e 100644
@@ -1910,7 +1910,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
 		    common->lun, lun);
 
 	/* Check the LUN */
-	if (common->lun >= 0 && common->lun < common->nluns) {
+	if (common->lun < common->nluns) {
 		curlun = &common->luns[common->lun];
 		common->curlun = curlun;
 		if (common->cmnd[0] != REQUEST_SENSE) {
drivers/usb/gadget/file_storage.c +1 -1
index a6eacb5..a9c5177 100644
@@ -2314,7 +2314,7 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
 		fsg->lun = lun;		// Use LUN from the command
 
 	/* Check the LUN */
-	if (fsg->lun >= 0 && fsg->lun < fsg->nluns) {
+	if (fsg->lun < fsg->nluns) {
 		fsg->curlun = curlun = &fsg->luns[fsg->lun];
 		if (fsg->cmnd[0] != REQUEST_SENSE) {
 			curlun->sense_data = SS_NO_SENSE;