diff mbox series

[4/5] 9p: virtio: skip incrementing unused variable

Message ID 20230427-scan-build-v1-4-efa05d65e2da@codewreck.org (mailing list archive)
State Superseded
Headers show
Series Fix scan-build warnings | expand

Commit Message

Dominique Martinet April 27, 2023, 11:23 a.m. UTC
Fix the following scan-build warning:
net/9p/trans_virtio.c:504:3: warning: Value stored to 'in' is never read [deadcode.DeadStores]
                in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM,
                ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm honestly not 100% sure about this one; I'm tempted to think we
could (should?) just check the return value of pack_sg_list_p to skip
the in_sgs++ and setting sgs[] if it didn't process anything, but I'm
not sure it should ever happen so this is probably fine as is.

Just removing the assignment at least makes it clear the return value
isn't used, so it's an improvement in terms of readability.

Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
 net/9p/trans_virtio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Horman May 2, 2023, 3:27 p.m. UTC | #1
On Thu, Apr 27, 2023 at 08:23:37PM +0900, Dominique Martinet wrote:
> Fix the following scan-build warning:
> net/9p/trans_virtio.c:504:3: warning: Value stored to 'in' is never read [deadcode.DeadStores]
>                 in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM,
>                 ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> I'm honestly not 100% sure about this one; I'm tempted to think we
> could (should?) just check the return value of pack_sg_list_p to skip
> the in_sgs++ and setting sgs[] if it didn't process anything, but I'm
> not sure it should ever happen so this is probably fine as is.
> 
> Just removing the assignment at least makes it clear the return value
> isn't used, so it's an improvement in terms of readability.
> 
> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index f3f678289423..e305071eb7b8 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -501,8 +501,8 @@  p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
 
 	if (in_pages) {
 		sgs[out_sgs + in_sgs++] = chan->sg + out + in;
-		in += pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM,
-				     in_pages, in_nr_pages, offs, inlen);
+		pack_sg_list_p(chan->sg, out + in, VIRTQUEUE_NUM,
+			       in_pages, in_nr_pages, offs, inlen);
 	}
 
 	BUG_ON(out_sgs + in_sgs > ARRAY_SIZE(sgs));