2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-18 10:13:57 +08:00

USB: serial: cast sizeof() to int when comparing with error code

Negative error code will be larger than sizeof().

Note that none of these bugs prevent errors from being detected, even if
the ir-usb one would cause a less precise debug message to printed.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
[ johan: add comment about implications ]
Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
Chengguang Xu 2018-06-25 15:35:18 +08:00 committed by Johan Hovold
parent 7daf201d7f
commit 3391ca1dcd
3 changed files with 3 additions and 3 deletions

View File

@ -132,7 +132,7 @@ irda_usb_find_class_desc(struct usb_serial *serial, unsigned int ifnum)
0, ifnum, desc, sizeof(*desc), 1000);
dev_dbg(&serial->dev->dev, "%s - ret=%d\n", __func__, ret);
if (ret < sizeof(*desc)) {
if (ret < (int)sizeof(*desc)) {
dev_dbg(&serial->dev->dev,
"%s - class descriptor read %s (%d)\n", __func__,
(ret < 0) ? "failed" : "too short", ret);

View File

@ -194,7 +194,7 @@ static inline int qt2_getregister(struct usb_device *dev,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
QT_SET_GET_REGISTER, 0xc0, reg,
uart, data, sizeof(*data), QT2_USB_TIMEOUT);
if (ret < sizeof(*data)) {
if (ret < (int)sizeof(*data)) {
if (ret >= 0)
ret = -EIO;
}

View File

@ -104,7 +104,7 @@ static inline int ssu100_getregister(struct usb_device *dev,
ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
QT_SET_GET_REGISTER, 0xc0, reg,
uart, data, sizeof(*data), 300);
if (ret < sizeof(*data)) {
if (ret < (int)sizeof(*data)) {
if (ret >= 0)
ret = -EIO;
}