diff mbox series

[3/5] 9p: virtio: make sure 'offs' is initialized in zc_request

Message ID 20230427-scan-build-v1-3-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
Similarly to the previous patch: offs can be used in handle_rerrors
without initializing on small payloads; in this case handle_rerrors will
not use it because of the size check, but it doesn't hurt to make sure
it is zero to please scan-build.

This fixes the following warning:
net/9p/trans_virtio.c:539:3: warning: 3rd function call argument is an uninitialized value [core.CallAndMessage]
                handle_rerror(req, in_hdr_len, offs, in_pages);
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

Comments

Simon Horman May 2, 2023, 3:27 p.m. UTC | #1
On Thu, Apr 27, 2023 at 08:23:36PM +0900, Dominique Martinet wrote:
> Similarly to the previous patch: offs can be used in handle_rerrors
> without initializing on small payloads; in this case handle_rerrors will
> not use it because of the size check, but it doesn't hurt to make sure
> it is zero to please scan-build.
> 
> This fixes the following warning:
> net/9p/trans_virtio.c:539:3: warning: 3rd function call argument is an uninitialized value [core.CallAndMessage]
>                 handle_rerror(req, in_hdr_len, offs, in_pages);
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 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 2c9495ccda6b..f3f678289423 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -428,7 +428,7 @@  p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
 	struct page **in_pages = NULL, **out_pages = NULL;
 	struct virtio_chan *chan = client->trans;
 	struct scatterlist *sgs[4];
-	size_t offs;
+	size_t offs = 0;
 	int need_drop = 0;
 	int kicked = 0;