Commit 3391ca1d authored by Chengguang Xu's avatar Chengguang Xu Committed by Johan Hovold

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: default avatarChengguang Xu <cgxu519@gmx.com>
[ johan: add comment about implications ]
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 7daf201d
......@@ -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;
}
......
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