From: Arseny Krasnov <arseny.krasnov@kaspersky.com>
To: Stefano Garzarella <sgarzare@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"David S. Miller" <davem@davemloft.net>,
Stefan Hajnoczi <stefanha@redhat.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next 3/3] vsock/virtio: remove redundant `copy_failed` variable
Date: Fri, 18 Jun 2021 17:55:00 +0300 [thread overview]
Message-ID: <22ee764c-ea35-7510-28c4-bccaf0ab7269@kaspersky.com> (raw)
In-Reply-To: <20210618133526.300347-4-sgarzare@redhat.com>
On 18.06.2021 16:35, Stefano Garzarella wrote:
> When memcpy_to_msg() fails in virtio_transport_seqpacket_do_dequeue(),
> we already set `dequeued_len` with the negative error value returned
> by memcpy_to_msg().
>
> So we can directly check `dequeued_len` value instead of using a
> dedicated flag variable to skip the copy path for the rest of
> fragments.
>
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> net/vmw_vsock/virtio_transport_common.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 23704a6bc437..f014ccfdd9c2 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -413,7 +413,6 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
> struct virtio_vsock_pkt *pkt;
> int dequeued_len = 0;
> size_t user_buf_len = msg_data_left(msg);
> - bool copy_failed = false;
> bool msg_ready = false;
>
> spin_lock_bh(&vvs->rx_lock);
> @@ -426,7 +425,7 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
> while (!msg_ready) {
> pkt = list_first_entry(&vvs->rx_queue, struct virtio_vsock_pkt, list);
>
> - if (!copy_failed) {
> + if (dequeued_len >= 0) {
> size_t pkt_len;
> size_t bytes_to_copy;
>
> @@ -443,11 +442,9 @@ static int virtio_transport_seqpacket_do_dequeue(struct vsock_sock *vsk,
>
> err = memcpy_to_msg(msg, pkt->buf, bytes_to_copy);
> if (err) {
> - /* Copy of message failed, set flag to skip
> - * copy path for rest of fragments. Rest of
> + /* Copy of message failed. Rest of
> * fragments will be freed without copy.
> */
> - copy_failed = true;
> dequeued_len = err;
> } else {
> user_buf_len -= bytes_to_copy;
LGTM
next prev parent reply other threads:[~2021-06-18 14:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 13:35 [PATCH net-next 0/3] vsock: small fixes for seqpacket support Stefano Garzarella
2021-06-18 13:35 ` [PATCH net-next 1/3] vsock: rename vsock_has_data() Stefano Garzarella
2021-06-18 14:50 ` Arseny Krasnov
2021-06-18 13:35 ` [PATCH net-next 2/3] vsock: rename vsock_wait_data() Stefano Garzarella
2021-06-18 14:50 ` Arseny Krasnov
2021-06-18 13:35 ` [PATCH net-next 3/3] vsock/virtio: remove redundant `copy_failed` variable Stefano Garzarella
2021-06-18 14:55 ` Arseny Krasnov [this message]
2021-06-18 20:10 ` [PATCH net-next 0/3] vsock: small fixes for seqpacket support patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=22ee764c-ea35-7510-28c4-bccaf0ab7269@kaspersky.com \
--to=arseny.krasnov@kaspersky.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®