virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix compile warnings in virtio_balloon
@ 2008-01-24 20:03 Anthony Liguori
  2008-01-24 22:14 ` Anthony Liguori
  2008-01-24 23:09 ` Rusty Russell
  0 siblings, 2 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-01-24 20:03 UTC (permalink / raw)
  To: virtualization; +Cc: Anthony Liguori

On x86_64, min was throwing a warning.  ARRAY_SIZE is unsigned long so let's
switch to using that for num.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 9de85ae..2f77bfe 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -82,7 +82,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
 	wait_for_completion(&vb->acked);
 }
 
-static void fill_balloon(struct virtio_balloon *vb, unsigned int num)
+static void fill_balloon(struct virtio_balloon *vb, unsigned long num)
 {
 	/* We can only do one array worth at a time. */
 	num = min(num, ARRAY_SIZE(vb->pfns));
@@ -92,7 +92,7 @@ static void fill_balloon(struct virtio_balloon *vb, unsigned int num)
 		if (!page) {
 			if (printk_ratelimit())
 				dev_printk(KERN_INFO, &vb->vdev->dev,
-					   "Out of puff! Can't get %u pages\n",
+					   "Out of puff! Can't get %lu pages\n",
 					   num);
 			/* Sleep for at least 1/5 of a second before retry. */
 			msleep(200);
@@ -121,7 +121,7 @@ static void release_pages_by_pfn(const u32 pfns[], unsigned int num)
 	}
 }
 
-static void leak_balloon(struct virtio_balloon *vb, unsigned int num)
+static void leak_balloon(struct virtio_balloon *vb, unsigned long num)
 {
 	struct page *page;

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

* Re: [PATCH] Fix compile warnings in virtio_balloon
  2008-01-24 20:03 [PATCH] Fix compile warnings in virtio_balloon Anthony Liguori
@ 2008-01-24 22:14 ` Anthony Liguori
  2008-01-24 23:09 ` Rusty Russell
  1 sibling, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-01-24 22:14 UTC (permalink / raw)
  To: virtualization

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

Anthony Liguori wrote:
> On x86_64, min was throwing a warning.  ARRAY_SIZE is unsigned long so let's
> switch to using that for num.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>   

Okay, that just changed the warning to occur on i386.  Please use the 
attached patch instead which just casts within the min macro.

Regards,

Anthony Liguori


[-- Attachment #2: virtio:balloon_min.diff --]
[-- Type: text/x-patch, Size: 1239 bytes --]

Subject: [PATCH] Fix compile warnings in virtio_balloon
Cc: Rusty Russell <rusty@rustcorp.com.au>

On x86_64, min was throwing a warning. Let's explicitly cast to avoid the
warning.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 9de85ae..cb7f1df 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -85,7 +85,7 @@ static void tell_host(struct virtio_balloon *vb, struct virtqueue *vq)
 static void fill_balloon(struct virtio_balloon *vb, unsigned int num)
 {
 	/* We can only do one array worth at a time. */
-	num = min(num, ARRAY_SIZE(vb->pfns));
+	num = min(num, (unsigned int)ARRAY_SIZE(vb->pfns));
 
 	for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) {
 		struct page *page = alloc_page(GFP_HIGHUSER | __GFP_NORETRY);
@@ -126,7 +126,7 @@ static void leak_balloon(struct virtio_balloon *vb, unsigned int num)
 	struct page *page;
 
 	/* We can only do one array worth at a time. */
-	num = min(num, ARRAY_SIZE(vb->pfns));
+	num = min(num, (unsigned int)ARRAY_SIZE(vb->pfns));
 
 	for (vb->num_pfns = 0; vb->num_pfns < num; vb->num_pfns++) {
 		page = list_first_entry(&vb->pages, struct page, lru);

[-- Attachment #3: Type: text/plain, Size: 184 bytes --]

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

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

* Re: [PATCH] Fix compile warnings in virtio_balloon
  2008-01-24 20:03 [PATCH] Fix compile warnings in virtio_balloon Anthony Liguori
  2008-01-24 22:14 ` Anthony Liguori
@ 2008-01-24 23:09 ` Rusty Russell
  2008-01-25 15:29   ` Anthony Liguori
  1 sibling, 1 reply; 4+ messages in thread
From: Rusty Russell @ 2008-01-24 23:09 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: virtualization

On Friday 25 January 2008 07:03:18 Anthony Liguori wrote:
> On x86_64, min was throwing a warning.  ARRAY_SIZE is unsigned long so
> let's switch to using that for num.

Creates warning on 32-bit.

How about this?
===

On x86_64, min was throwing a warning.  size_t is correct for 32 and 64.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -82,7 +82,7 @@ static void tell_host(struct virtio_ball
 	wait_for_completion(&vb->acked);
 }
 
-static void fill_balloon(struct virtio_balloon *vb, unsigned int num)
+static void fill_balloon(struct virtio_balloon *vb, size_t num)
 {
 	/* We can only do one array worth at a time. */
 	num = min(num, ARRAY_SIZE(vb->pfns));
@@ -92,7 +92,7 @@ static void fill_balloon(struct virtio_b
 		if (!page) {
 			if (printk_ratelimit())
 				dev_printk(KERN_INFO, &vb->vdev->dev,
-					   "Out of puff! Can't get %u pages\n",
+					   "Out of puff! Can't get %zu pages\n",
 					   num);
 			/* Sleep for at least 1/5 of a second before retry. */
 			msleep(200);
@@ -121,7 +121,7 @@ static void release_pages_by_pfn(const u
 	}
 }
 
-static void leak_balloon(struct virtio_balloon *vb, unsigned int num)
+static void leak_balloon(struct virtio_balloon *vb, size_t num)
 {
 	struct page *page;

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

* Re: [PATCH] Fix compile warnings in virtio_balloon
  2008-01-24 23:09 ` Rusty Russell
@ 2008-01-25 15:29   ` Anthony Liguori
  0 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2008-01-25 15:29 UTC (permalink / raw)
  To: Rusty Russell; +Cc: virtualization

Rusty Russell wrote:
> On Friday 25 January 2008 07:03:18 Anthony Liguori wrote:
>   
>> On x86_64, min was throwing a warning.  ARRAY_SIZE is unsigned long so
>> let's switch to using that for num.
>>     
>
> Creates warning on 32-bit.
>
> How about this?
>   
Yeah, that's fine.

Regards,

Anthony Liguori
> ===
>
> On x86_64, min was throwing a warning.  size_t is correct for 32 and 64.
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -82,7 +82,7 @@ static void tell_host(struct virtio_ball
>  	wait_for_completion(&vb->acked);
>  }
>
> -static void fill_balloon(struct virtio_balloon *vb, unsigned int num)
> +static void fill_balloon(struct virtio_balloon *vb, size_t num)
>  {
>  	/* We can only do one array worth at a time. */
>  	num = min(num, ARRAY_SIZE(vb->pfns));
> @@ -92,7 +92,7 @@ static void fill_balloon(struct virtio_b
>  		if (!page) {
>  			if (printk_ratelimit())
>  				dev_printk(KERN_INFO, &vb->vdev->dev,
> -					   "Out of puff! Can't get %u pages\n",
> +					   "Out of puff! Can't get %zu pages\n",
>  					   num);
>  			/* Sleep for at least 1/5 of a second before retry. */
>  			msleep(200);
> @@ -121,7 +121,7 @@ static void release_pages_by_pfn(const u
>  	}
>  }
>
> -static void leak_balloon(struct virtio_balloon *vb, unsigned int num)
> +static void leak_balloon(struct virtio_balloon *vb, size_t num)
>  {
>  	struct page *page;
>
>   

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

end of thread, other threads:[~2008-01-25 15:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-24 20:03 [PATCH] Fix compile warnings in virtio_balloon Anthony Liguori
2008-01-24 22:14 ` Anthony Liguori
2008-01-24 23:09 ` Rusty Russell
2008-01-25 15:29   ` Anthony Liguori

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