All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>
Cc: jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
	virtualization@lists.linux.dev
Subject: Re: [PATCH] virtio_ring:  fix uninitialized symbol warnings
Date: Wed, 6 Aug 2025 16:48:54 -0400	[thread overview]
Message-ID: <20250806164805-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250806124101.3574834-1-chelsyratnawat2001@gmail.com>

On Wed, Aug 06, 2025 at 05:41:01AM -0700, Chelsy Ratnawat wrote:
> Fix below smatch warnings:
>   virtio_ring.c:1566 virtqueue_add_packed() error: uninitialized symbol 'prev'.
>   virtio_ring.c:1574 virtqueue_add_packed() error: uninitialized symbol 'head_flags'.
>   virtio_ring.c:635 virtqueue_add_split() error: uninitialized symbol 'prev'.
> 
> No functional changes intended.
> 
> Signed-off-by: Chelsy Ratnawat <chelsyratnawat2001@gmail.com>


Sorry we don't mechanically "fix" warnings like this. 
Please analyse the code and report whether the issue is
real or a false positive.


> ---
>  drivers/virtio/virtio_ring.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index f5062061c408..03aa08aaebed 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -540,7 +540,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq,
>  	struct vring_desc_extra *extra;
>  	struct scatterlist *sg;
>  	struct vring_desc *desc;
> -	unsigned int i, n, avail, descs_used, prev, err_idx;
> +	unsigned int i, n, avail, descs_used, prev = 0, err_idx;
>  	int head;
>  	bool indirect;
>  
> @@ -1459,8 +1459,8 @@ static inline int virtqueue_add_packed(struct virtqueue *_vq,
>  	struct vring_packed_desc *desc;
>  	struct scatterlist *sg;
>  	unsigned int i, n, c, descs_used, err_idx, len;
> -	__le16 head_flags, flags;
> -	u16 head, id, prev, curr, avail_used_flags;
> +	__le16 head_flags = 0, flags;
> +	u16 head, id, prev = 0, curr, avail_used_flags;
>  	int err;
>  
>  	START_USE(vq);
> -- 
> 2.47.3


      reply	other threads:[~2025-08-06 20:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-06 12:41 [PATCH] virtio_ring: fix uninitialized symbol warnings Chelsy Ratnawat
2025-08-06 20:48 ` Michael S. Tsirkin [this message]

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=20250806164805-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=chelsyratnawat2001@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.