virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [patch] vhost/scsi: silence uninitialized variable warning
@ 2017-01-12 18:45 Dan Carpenter
  2017-01-13  3:12 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2017-01-12 18:45 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: kernel-janitors, kvm, virtualization

This is to silence an uninitialized variable warning in debug output.
The problem is this line:

	pr_debug("vhost_get_vq_desc: head: %d, out: %u in: %u\n",
		 head, out, in);

If "head == vq->num" is true on the first iteration then "out" and "in"
aren't initialized.  We handle that a few lines after the printk.  I was
tempted to just delete the pr_debug() but I decided to just initialize
them to zero instead.

Also checkpatch.pl complains if variables are declared as just
"unsigned" without the "int".

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 253310c..b98dac1 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -843,7 +843,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
 	struct iov_iter out_iter, in_iter, prot_iter, data_iter;
 	u64 tag;
 	u32 exp_data_len, data_direction;
-	unsigned out, in;
+	unsigned int out = 0, in = 0;
 	int head, ret, prot_bytes;
 	size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp);
 	size_t out_size, in_size;

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

* Re: [patch] vhost/scsi: silence uninitialized variable warning
  2017-01-12 18:45 [patch] vhost/scsi: silence uninitialized variable warning Dan Carpenter
@ 2017-01-13  3:12 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2017-01-13  3:12 UTC (permalink / raw)
  To: Dan Carpenter, Michael S. Tsirkin; +Cc: kernel-janitors, kvm, virtualization



On 2017年01月13日 02:45, Dan Carpenter wrote:
> This is to silence an uninitialized variable warning in debug output.
> The problem is this line:
>
> 	pr_debug("vhost_get_vq_desc: head: %d, out: %u in: %u\n",
> 		 head, out, in);
>
> If "head == vq->num" is true on the first iteration then "out" and "in"
> aren't initialized.  We handle that a few lines after the printk.  I was
> tempted to just delete the pr_debug() but I decided to just initialize
> them to zero instead.
>
> Also checkpatch.pl complains if variables are declared as just
> "unsigned" without the "int".
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
> index 253310c..b98dac1 100644
> --- a/drivers/vhost/scsi.c
> +++ b/drivers/vhost/scsi.c
> @@ -843,7 +843,7 @@ vhost_scsi_handle_vq(struct vhost_scsi *vs, struct vhost_virtqueue *vq)
>   	struct iov_iter out_iter, in_iter, prot_iter, data_iter;
>   	u64 tag;
>   	u32 exp_data_len, data_direction;
> -	unsigned out, in;
> +	unsigned int out = 0, in = 0;
>   	int head, ret, prot_bytes;
>   	size_t req_size, rsp_size = sizeof(struct virtio_scsi_cmd_resp);
>   	size_t out_size, in_size;

Acked-by: Jason Wang <jasowang@redhat.com>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

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

end of thread, other threads:[~2017-01-13  3:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-12 18:45 [patch] vhost/scsi: silence uninitialized variable warning Dan Carpenter
2017-01-13  3:12 ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).