virtio: fix "warning: ‘queue’ may be used uninitialized"
PATCH 1/1 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.
---
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio_ring.c +1 -1
@@ -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;
Signature · 6 lines
Jeff Mahoney SUSE Labs _______________________________________________ Virtualization mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 9 lines · Jeff Mahoney
This fixes the following warning:
drivers/virtio/virtio_ring.c:1032:5: warning: ‘queue’ may be used uninitialized in this functionThe conditions that govern when queue is set aren't apparent to gcc.
Setting queue = NULL clears the warning.
Signed-off-by Jeff Mahoney <[email protected]>
Which gcc version produces this warning?
I do not seem to see it with gcc 5.3.1.
Also - use uninitialized_var then?
Quoted 20 lines
---
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/virtio/virtio_ring.c +1
-1@@ -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;Signature · 3 lines
-- Jeff Mahoney SUSE Labs
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 5 lines · Michael S. Tsirkin
Quoted 4 lines · Jeff Mahoney
This fixes the following warning:
drivers/virtio/virtio_ring.c:1032:5: warning: ‘queue’ may be used uninitialized in this function
Quoted 8 lines
Quoted 5 lines
The conditions that govern when queue is set aren't apparent to gcc.
Setting queue = NULL clears the warning.
Signed-off-by Jeff Mahoney <[email protected]>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)
Quoted 1 line
Also - use
uninitialized_varthen?
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
Quoted 21 lines
Quoted 20 lines
---
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/virtio/virtio_ring.c +1
-1@@ -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;Signature · 3 lines
-- Jeff Mahoney SUSE Labs
Signature · 2 lines
Jeff Mahoney SUSE Labs
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Michael S. Tsirkin
maintainerQuoted 8 lines · Jeff Mahoney
Quoted 7 lines · Michael S. Tsirkin
Quoted 6 lines · Jeff Mahoney
This fixes the following warning:
drivers/virtio/virtio_ring.c:1032:5: warning: ‘queue’ may be used uninitialized in this functionThe conditions that govern when queue is set aren't apparent to gcc.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Setting queue = NULL clears the warning.
Signed-off-by Jeff Mahoney <[email protected]>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.
Quoted 6 lines
Quoted 1 line
Also - use
uninitialized_varthen?If it were a fast path, sure, but otherwise the use of
uninitialized_varjust 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.
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
---
drivers/virtio/virtio_ring.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/virtio/virtio_ring.c +1
-1@@ -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;
Quoted 10 lines
Quoted 4 lines
Quoted 3 lines
Signature · 2 lines
Jeff Mahoney SUSE LabsSignature · 2 lines
Jeff Mahoney SUSE Labs
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization