OSDN Git Service

USB: serial: cast sizeof() to int when comparing with error code
authorChengguang Xu <cgxu519@gmx.com>
Mon, 25 Jun 2018 07:35:18 +0000 (15:35 +0800)
committerJohan Hovold <johan@kernel.org>
Mon, 25 Jun 2018 08:34:31 +0000 (10:34 +0200)
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>
drivers/usb/serial/ir-usb.c
drivers/usb/serial/quatech2.c
drivers/usb/serial/ssu100.c

index 24b06c7..7643716 100644 (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);
index 958e12e..ff2322e 100644 (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;
        }
index 2083c26..0900b47 100644 (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;
        }