linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* usb: cast sizeof() to int when comparing with error code
@ 2018-06-25  7:35 Chengguang Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Chengguang Xu @ 2018-06-25  7:35 UTC (permalink / raw)
  To: johan, gregkh; +Cc: linux-usb, Chengguang Xu

Negative error code will be larger than sizeof().

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 drivers/usb/serial/ir-usb.c   | 2 +-
 drivers/usb/serial/quatech2.c | 2 +-
 drivers/usb/serial/ssu100.c   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/serial/ir-usb.c b/drivers/usb/serial/ir-usb.c
index 24b06c7e5e2d..7643716b5299 100644
--- a/drivers/usb/serial/ir-usb.c
+++ b/drivers/usb/serial/ir-usb.c
@@ -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);
diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c
index 958e12e1e7c7..ff2322ea5e14 100644
--- a/drivers/usb/serial/quatech2.c
+++ b/drivers/usb/serial/quatech2.c
@@ -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;
 	}
diff --git a/drivers/usb/serial/ssu100.c b/drivers/usb/serial/ssu100.c
index 2083c267787b..0900b47b5f57 100644
--- a/drivers/usb/serial/ssu100.c
+++ b/drivers/usb/serial/ssu100.c
@@ -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;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* usb: cast sizeof() to int when comparing with error code
@ 2018-06-25  8:19 Johan Hovold
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Hovold @ 2018-06-25  8:19 UTC (permalink / raw)
  To: Chengguang Xu; +Cc: johan, gregkh, linux-usb

On Mon, Jun 25, 2018 at 03:35:18PM +0800, Chengguang Xu wrote:
> Negative error code will be larger than sizeof().

Good catch!

I was gonna ask you to submit this as three separate patches to
facilitate stable backports, but fortunately it appears none of these
have any bad implications (besides possibly the ir-usb one printing a
less descriptive debug message).

So I'll queue this one of up for -next.

Thanks,
Johan
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-25  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-25  8:19 usb: cast sizeof() to int when comparing with error code Johan Hovold
  -- strict thread matches above, loose matches on Subject: below --
2018-06-25  7:35 Chengguang Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).