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 коммит произвёл Johan Hovold
Родитель 7daf201d7f
Коммит 3391ca1dcd
3 изменённых файлов: 3 добавлений и 3 удалений

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}