Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1414581pxj; Fri, 18 Jun 2021 06:39:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymQJzSvZOUIV6AAq8pF7hfBnE4yffK14pDxyLS60v6etHrYo3ENfvbfqG1MHF8Eti6syxF X-Received: by 2002:aa7:d305:: with SMTP id p5mr4927159edq.167.1624023594624; Fri, 18 Jun 2021 06:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624023594; cv=none; d=google.com; s=arc-20160816; b=WLf9xloRODCzWhaEJufPLgK4Po+SH0JZZCWbO+Nl5hDJdUcRkXTGJ/QqLcFgpHyXs+ ZfQsFnUXbvjfTZ45I95tXXr1CohjHtpP93cHidZBbOZSvaTC0WN6qT8bBGPQSx51Qc9V tycSRjz3CrfYZ0jqgq8ADrmQI3hziinfly35YsPF6GOcQJIh7EIqM/qliEB+W6S0SsZ8 i7EPEM5x1EfmKhRlYR+n3kYfTfOhpPgkofzObpkToooIMFR+C5LOPeQm1WBuUQv2sBLf Os+Y85CXVZv6g1BfWZYmuJiEUB5hVb/F4feFG9jF/n1GU4fxDv6Awx2mHd7iF+UGM5E1 1pxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KFwIb7IPOZRbP1IQ9mV70O4nT0A/GjnYdmBaTej5bMs=; b=UAAuNOyU+McKkioUk0q/628SB9HDBmXoMPswG5P3jMCtJ2md6C4dBvSds4gSLP1uZR BI52hjXZNSTiqAS16I9A2xOffgiED4GrfDR+njuHcDYH7r8rWzSWvNQgegolQ4mpegpC +7ggVjlt6vdIOZMXy4oWSpYQqPG3Dj4/C/MwxZ2FtSpK338wKkXXw5K83u83ew6jRMcj RyoaNBp2NG/6zTwcDAP7orkBd4Hsrqn4Xe/UaU/tWfwMw4bGYdhizOstQLeobX1tWzCN 7MMxIJf/h3C6aW+E5Ftn/TlTbC5LyvNAoGYHuyY5Ckut0xV18DSj2ya1rXZ0F5wdO1xc 4Unw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RaRIQ3UC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si8832642ede.200.2021.06.18.06.39.31; Fri, 18 Jun 2021 06:39:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RaRIQ3UC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234110AbhFRNiY (ORCPT + 99 others); Fri, 18 Jun 2021 09:38:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60933 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233934AbhFRNiJ (ORCPT ); Fri, 18 Jun 2021 09:38:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624023358; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KFwIb7IPOZRbP1IQ9mV70O4nT0A/GjnYdmBaTej5bMs=; b=RaRIQ3UCXtS9EM0rBCx5X/A/jead77kOXkU2ocQwROOktwYZix3fLpnTIDjp4zMG1t9FeU H+tU3fW5czb1MRjHgMm7whhqlUfuxfTkhrSfQ31zyxZMjIjbnsa6dhPuuCphoWei0Ay+XA k++SlRSC74v4x5twNpQMJlOmDFhgufQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-283-12QN6s9jMYqyi6bKQyOXnw-1; Fri, 18 Jun 2021 09:35:55 -0400 X-MC-Unique: 12QN6s9jMYqyi6bKQyOXnw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B98A8100C666; Fri, 18 Jun 2021 13:35:53 +0000 (UTC) Received: from steredhat.lan (ovpn-115-127.ams2.redhat.com [10.36.115.127]) by smtp.corp.redhat.com (Postfix) with ESMTP id B17261000324; Fri, 18 Jun 2021 13:35:47 +0000 (UTC) From: Stefano Garzarella To: netdev@vger.kernel.org Cc: Arseny Krasnov , kvm@vger.kernel.org, Stefano Garzarella , Jakub Kicinski , virtualization@lists.linux-foundation.org, "David S. Miller" , Stefan Hajnoczi , linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] vsock/virtio: remove redundant `copy_failed` variable Date: Fri, 18 Jun 2021 15:35:26 +0200 Message-Id: <20210618133526.300347-4-sgarzare@redhat.com> In-Reply-To: <20210618133526.300347-1-sgarzare@redhat.com> References: <20210618133526.300347-1-sgarzare@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; -- 2.31.1