Skip to contentSkip to conversation

staging: most: hdm-usb: Fix sparse warning cast to restricted __le16

PATCH In review Eric Salem 3 participants 4 messages Jan 10, 2017 – Jan 11, 2017

Subsystems (2)
lore
Share & tools
lore

Eric Salem

author
#0 lore raw

PATCH 1/1 staging: most: hdm-usb: Fix sparse warning cast to restricted __le16

Fixed the following sparse warning:

drivers/staging/most/hdm-usb/hdm_usb.c:158:16: warning:
cast to restricted __le16

by correcting the variable's type (also updated sizeof).

---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-usb/hdm_usb.c +2 -2
index d6db0bd..01e3a31 100644
@@ -145,7 +145,7 @@ static void wq_netinfo(struct work_struct *wq_obj);
 static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 {
 	int retval;
-	u16 *dma_buf = kzalloc(sizeof(u16), GFP_KERNEL);
+	__le16 *dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL);
 	u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
 
 	if (!dma_buf)
@@ -154,7 +154,7 @@ static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 	retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
 				 DRCI_READ_REQ, req_type,
 				 0x0000,
-				 reg, dma_buf, sizeof(u16), 5 * HZ);
+				 reg, dma_buf, sizeof(*dma_buf), 5 * HZ);
 	*buf = le16_to_cpu(*dma_buf);
 	kfree(dma_buf);
 
Signature · 1 line
2.9.3
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · On Mon, 9 Jan 2017 21:25:56 -0600 Eric Salem <[email protected]> wrote:

Fixed the following sparse warning:

drivers/staging/most/hdm-usb/hdm_usb.c:158:16: warning:
cast to restricted __le16

by correcting the variable's type (also updated sizeof).

Quoted 26 lines
---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-usb/hdm_usb.c +2 -2
index d6db0bd..01e3a31 100644
@@ -145,7 +145,7 @@ static void wq_netinfo(struct work_struct *wq_obj);
 static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 {
 	int retval;
-	u16 *dma_buf = kzalloc(sizeof(u16), GFP_KERNEL);
+	__le16 *dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL);
 	u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
 
 	if (!dma_buf)
@@ -154,7 +154,7 @@ static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 	retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
 				 DRCI_READ_REQ, req_type,
 				 0x0000,
-				 reg, dma_buf, sizeof(u16), 5 * HZ);
+				 reg, dma_buf, sizeof(*dma_buf), 5 * HZ);
 	*buf = le16_to_cpu(*dma_buf);
 	kfree(dma_buf);
 
maintainer
#2 lore raw
In reply to Eric Salem
Quoted 5 lines · Eric Salem

Fixed the following sparse warning:

drivers/staging/most/hdm-usb/hdm_usb.c:158:16: warning:
cast to restricted __le16

Quoted 7 lines

by correcting the variable's type (also updated sizeof).

---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

This patch doesn't apply against linux-next, can you refresh it and resend?

thanks,

greg k-h

author
#3 lore raw

PATCH v2 1/1 staging: most: hdm-usb: Fix mismatch between types used in sizeof operator

Fixed mismatch between types used in sizeof operator.

---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/most/hdm-usb/hdm_usb.c +2 -2
index 8a6da16..01e3a31 100644
@@ -145,7 +145,7 @@ static void wq_netinfo(struct work_struct *wq_obj);
 static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 {
 	int retval;
-	__le16 *dma_buf = kzalloc(sizeof(__le16), GFP_KERNEL);
+	__le16 *dma_buf = kzalloc(sizeof(*dma_buf), GFP_KERNEL);
 	u8 req_type = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE;
 
 	if (!dma_buf)
@@ -154,7 +154,7 @@ static inline int drci_rd_reg(struct usb_device *dev, u16 reg, u16 *buf)
 	retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
 				 DRCI_READ_REQ, req_type,
 				 0x0000,
-				 reg, dma_buf, sizeof(u16), 5 * HZ);
+				 reg, dma_buf, sizeof(*dma_buf), 5 * HZ);
 	*buf = le16_to_cpu(*dma_buf);
 	kfree(dma_buf);
 
Signature · 1 line
2.9.3
Quoted 21 lines · Greg KH
Quoted 5 lines · Eric Salem

Fixed the following sparse warning:

drivers/staging/most/hdm-usb/hdm_usb.c:158:16: warning:
cast to restricted __le16

Quoted 7 lines

by correcting the variable's type (also updated sizeof).

---
 drivers/staging/most/hdm-usb/hdm_usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

This patch doesn't apply against linux-next, can you refresh it and resend?

thanks,

greg k-h