Commit 98f3a1b9 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Felipe Balbi

usb: gadget: mass_storage: remove >= 0 check for unsigned type

| In file included from drivers/usb/gadget/acm_ms.c:43:
| f_mass_storage.c:2199:18: warning: comparison of unsigned expression >= 0 is always true  [-Wtautological-compare]
|         if (common->lun >= 0 && common->lun < common->nluns)
|             ~~~~~~~~~~~ ^  ~

common->lun is defined as "unsigned int" so its value is always >= 0.
It is assigned via cbw->Lun which is defined as u8 so it is also not
abused as -1.

[ mina86@mina86.com : make lun unsigned int and use %u in DBG() macro for it ]
Signed-off-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent b6424353
...@@ -1691,7 +1691,7 @@ static int check_command(struct fsg_common *common, int cmnd_size, ...@@ -1691,7 +1691,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
int needs_medium, const char *name) int needs_medium, const char *name)
{ {
int i; int i;
int lun = common->cmnd[1] >> 5; unsigned int lun = common->cmnd[1] >> 5;
static const char dirletter[4] = {'u', 'o', 'i', 'n'}; static const char dirletter[4] = {'u', 'o', 'i', 'n'};
char hdlen[20]; char hdlen[20];
struct fsg_lun *curlun; struct fsg_lun *curlun;
...@@ -1757,7 +1757,7 @@ static int check_command(struct fsg_common *common, int cmnd_size, ...@@ -1757,7 +1757,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
/* Check that the LUN values are consistent */ /* Check that the LUN values are consistent */
if (common->lun != lun) if (common->lun != lun)
DBG(common, "using LUN %d from CBW, not LUN %d from CDB\n", DBG(common, "using LUN %u from CBW, not LUN %u from CDB\n",
common->lun, lun); common->lun, lun);
/* Check the LUN */ /* Check the LUN */
...@@ -1777,7 +1777,7 @@ static int check_command(struct fsg_common *common, int cmnd_size, ...@@ -1777,7 +1777,7 @@ static int check_command(struct fsg_common *common, int cmnd_size,
*/ */
if (common->cmnd[0] != INQUIRY && if (common->cmnd[0] != INQUIRY &&
common->cmnd[0] != REQUEST_SENSE) { common->cmnd[0] != REQUEST_SENSE) {
DBG(common, "unsupported LUN %d\n", common->lun); DBG(common, "unsupported LUN %u\n", common->lun);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -2169,7 +2169,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh) ...@@ -2169,7 +2169,7 @@ static int received_cbw(struct fsg_dev *fsg, struct fsg_buffhd *bh)
if (common->data_size == 0) if (common->data_size == 0)
common->data_dir = DATA_DIR_NONE; common->data_dir = DATA_DIR_NONE;
common->lun = cbw->Lun; common->lun = cbw->Lun;
if (common->lun >= 0 && common->lun < common->nluns) if (common->lun < common->nluns)
common->curlun = &common->luns[common->lun]; common->curlun = &common->luns[common->lun];
else else
common->curlun = NULL; common->curlun = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment