[PATCH] USB: serial: iuu_phoenix: fix checkpatch memset warning

Utkarsh Verma utkarshverma294 at gmail.com
Tue Aug 3 14:20:45 UTC 2021


This fixed the below checkpatch issue:
WARNING: single byte memset is suspicious. Swapped 2nd/3rd argument?

Logically the code is correct, but it is unusual to use memset for a
single byte only. The same can be achieved by using a simple
assignment.

Signed-off-by: Utkarsh Verma <utkarshverma294 at gmail.com>
Suggested-by: Lukas Bulwahn <lukas.bulwahn at gmail.com>
---
 drivers/usb/serial/iuu_phoenix.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index 19753611e..6bab12f4f 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -253,7 +253,7 @@ static int iuu_status(struct usb_serial_port *port)
 {
 	int result;
 
-	memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1);
+	*(char *)port->write_urb->transfer_buffer = IUU_GET_STATE_REGISTER;
 	usb_fill_bulk_urb(port->write_urb, port->serial->dev,
 			  usb_sndbulkpipe(port->serial->dev,
 					  port->bulk_out_endpointAddress),
@@ -1056,7 +1056,7 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port)
 
 	dev_dbg(dev, "%s - initialization done\n", __func__);
 
-	memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
+	*(char *)port->write_urb->transfer_buffer = IUU_UART_RX;
 	usb_fill_bulk_urb(port->write_urb, port->serial->dev,
 			  usb_sndbulkpipe(port->serial->dev,
 					  port->bulk_out_endpointAddress),
-- 
2.17.1



More information about the Linux-kernel-mentees mailing list