All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
@ 2016-04-04 18:14 Jeff Mahoney
  2016-04-05  8:04 ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Mahoney @ 2016-04-04 18:14 UTC (permalink / raw)
  To: Michael S. Tsirkin, virtualization

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>
---

 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
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-04-05  8:04 UTC (permalink / raw)
  To: Jeff Mahoney; +Cc: virtualization

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.
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
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
  2016-04-05  8:04 ` Michael S. Tsirkin
@ 2016-04-05 13:34   ` Jeff Mahoney
  2016-04-05 14:00     ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Mahoney @ 2016-04-05 13:34 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: virtualization


[-- Attachment #1.1.1: Type: text/plain, Size: 1283 bytes --]

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)

> 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


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 881 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] virtio: fix "warning: ‘queue’ may be used uninitialized"
  2016-04-05 13:34   ` Jeff Mahoney
@ 2016-04-05 14:00     ` Michael S. Tsirkin
  0 siblings, 0 replies; 4+ messages in thread
From: Michael S. Tsirkin @ 2016-04-05 14:00 UTC (permalink / raw)
  To: Jeff Mahoney; +Cc: virtualization

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-04-05 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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.