From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jeff Mahoney <jeffm@suse.com>
Cc: virtualization@lists.linux-foundation.org
Subject: Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
Date: Tue, 5 Apr 2016 17:00:27 +0300 [thread overview]
Message-ID: <20160405165814-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <5703BEE0.5020206@suse.com>
On Tue, Apr 05, 2016 at 09:34:24AM -0400, Jeff Mahoney wrote:
> On 4/5/16 4:04 AM, Michael S. Tsirkin wrote:
> > On Mon, Apr 04, 2016 at 02:14:19PM -0400, Jeff Mahoney wrote:
> >> This fixes the following warning:
> >> drivers/virtio/virtio_ring.c:1032:5: warning: ‘queue’ may be used
> >> uninitialized in this function
> >>
> >> The conditions that govern when queue is set aren't apparent to gcc.
> >>
> >> Setting queue = NULL clears the warning.
> >>
> >> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> >
> > Which gcc version produces this warning?
> > I do not seem to see it with gcc 5.3.1.
>
> gcc version 4.8.5 (SUSE Linux)
Looks like a minor compiler bug then, fixed since.
I don't think we need to worry about that this.
> > Also - use uninitialized_var then?
>
> If it were a fast path, sure, but otherwise the use of uninitialized_var
> just makes similar issues harder to debug if the code changes.
>
> -Jeff
Same does = NULL though. It's not like things will work with queue ==
NULL, so it'll still crash if it's not inited properly.
> >> ---
> >>
> >> drivers/virtio/virtio_ring.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> --- a/drivers/virtio/virtio_ring.c
> >> +++ b/drivers/virtio/virtio_ring.c
> >> @@ -1006,7 +1006,7 @@ struct virtqueue *vring_create_virtqueue
> >> const char *name)
> >> {
> >> struct virtqueue *vq;
> >> - void *queue;
> >> + void *queue = NULL;
> >> dma_addr_t dma_addr;
> >> size_t queue_size_in_bytes;
> >> struct vring vring;
> >>
> >> --
> >> Jeff Mahoney
> >> SUSE Labs
> >
>
>
> --
> Jeff Mahoney
> SUSE Labs
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
prev parent reply other threads:[~2016-04-05 14:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-04 18:14 [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized" Jeff Mahoney
2016-04-05 8:04 ` Michael S. Tsirkin
2016-04-05 13:34 ` Jeff Mahoney
2016-04-05 14:00 ` 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=20160405165814-mutt-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=jeffm@suse.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