Jeff Mahoney
2016-Apr-04 18:14 UTC
[PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
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 at suse.com> --- 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
Michael S. Tsirkin
2016-Apr-05 08:04 UTC
[PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
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 at suse.com>Which gcc version produces this warning? I do not seem to see it with gcc 5.3.1. Also - use uninitialized_var then?> --- > > 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
2016-Apr-05 13:34 UTC
Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
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 at 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)> 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>> --- >> >> 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 881 bytes Desc: OpenPGP digital signature URL: <http://lists.linuxfoundation.org/pipermail/virtualization/attachments/20160405/a4c72d48/attachment.sig>
Apparently Analagous Threads
- [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
- Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
- Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
- [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
- [Patch v2] btrfs: use file_remove_suid() after i_mutex is held