linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbip: Replace unused kvec array with single variable in vhci_send_cmd_unlink()
@ 2019-06-03 15:02 Suwan Kim
  2019-06-04  0:56 ` shuah
  0 siblings, 1 reply; 2+ messages in thread
From: Suwan Kim @ 2019-06-03 15:02 UTC (permalink / raw)
  To: shuah, valentina.manea.m, gregkh; +Cc: linux-usb, linux-kernel, Suwan Kim

vhci_send_cmd_unlink() declears kvec array of size 3 but it actually
uses just one element of the array. So, remove kvec array and replace
it with single kvec variable.

Signed-off-by: Suwan Kim <suwan.kim027@gmail.com>
---
 drivers/usb/usbip/vhci_tx.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index 9aed15a358b7..2fa26d0578d7 100644
--- a/drivers/usb/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
@@ -144,16 +144,14 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
 	struct vhci_unlink *unlink = NULL;
 
 	struct msghdr msg;
-	struct kvec iov[3];
+	struct kvec iov;
 	size_t txsize;
-
 	size_t total_size = 0;
 
 	while ((unlink = dequeue_from_unlink_tx(vdev)) != NULL) {
 		int ret;
 		struct usbip_header pdu_header;
 
-		txsize = 0;
 		memset(&pdu_header, 0, sizeof(pdu_header));
 		memset(&msg, 0, sizeof(msg));
 		memset(&iov, 0, sizeof(iov));
@@ -169,11 +167,11 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
 
 		usbip_header_correct_endian(&pdu_header, 1);
 
-		iov[0].iov_base = &pdu_header;
-		iov[0].iov_len  = sizeof(pdu_header);
-		txsize += sizeof(pdu_header);
+		iov.iov_base = &pdu_header;
+		iov.iov_len  = sizeof(pdu_header);
+		txsize = sizeof(pdu_header);
 
-		ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize);
+		ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, &iov, 1, txsize);
 		if (ret != txsize) {
 			pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
 			       txsize);
-- 
2.20.1


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

* Re: [PATCH] usbip: Replace unused kvec array with single variable in vhci_send_cmd_unlink()
  2019-06-03 15:02 [PATCH] usbip: Replace unused kvec array with single variable in vhci_send_cmd_unlink() Suwan Kim
@ 2019-06-04  0:56 ` shuah
  0 siblings, 0 replies; 2+ messages in thread
From: shuah @ 2019-06-04  0:56 UTC (permalink / raw)
  To: Suwan Kim, valentina.manea.m, gregkh
  Cc: linux-usb, linux-kernel, shuah, Shuah Khan

On 6/3/19 9:02 AM, Suwan Kim wrote:
> vhci_send_cmd_unlink() declears kvec array of size 3 but it actually
> uses just one element of the array. So, remove kvec array and replace
> it with single kvec variable.
> 
> Signed-off-by: Suwan Kim <suwan.kim027@gmail.com>
> ---
>   drivers/usb/usbip/vhci_tx.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
> index 9aed15a358b7..2fa26d0578d7 100644
> --- a/drivers/usb/usbip/vhci_tx.c
> +++ b/drivers/usb/usbip/vhci_tx.c
> @@ -144,16 +144,14 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
>   	struct vhci_unlink *unlink = NULL;
>   
>   	struct msghdr msg;
> -	struct kvec iov[3];
> +	struct kvec iov;
>   	size_t txsize;
> -
>   	size_t total_size = 0;
>   
>   	while ((unlink = dequeue_from_unlink_tx(vdev)) != NULL) {
>   		int ret;
>   		struct usbip_header pdu_header;
>   
> -		txsize = 0;
>   		memset(&pdu_header, 0, sizeof(pdu_header));
>   		memset(&msg, 0, sizeof(msg));
>   		memset(&iov, 0, sizeof(iov));
> @@ -169,11 +167,11 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
>   
>   		usbip_header_correct_endian(&pdu_header, 1);
>   
> -		iov[0].iov_base = &pdu_header;
> -		iov[0].iov_len  = sizeof(pdu_header);
> -		txsize += sizeof(pdu_header);
> +		iov.iov_base = &pdu_header;
> +		iov.iov_len  = sizeof(pdu_header);
> +		txsize = sizeof(pdu_header);
>   
> -		ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize);
> +		ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, &iov, 1, txsize);
>   		if (ret != txsize) {
>   			pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
>   			       txsize);
> 

Looks good to me.

Acked-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

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

end of thread, other threads:[~2019-06-04  0:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-03 15:02 [PATCH] usbip: Replace unused kvec array with single variable in vhci_send_cmd_unlink() Suwan Kim
2019-06-04  0:56 ` shuah

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).