mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: fs.c fix cast
@ 2012-09-11  5:31 Alexander Aring
  2012-09-11  7:20 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Aring @ 2012-09-11  5:31 UTC (permalink / raw)
  To: barebox

Fix casting on min argument, to avoid warnings on 64bit build.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 fs/fs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 38917bf..db4621a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1525,7 +1525,9 @@ ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulon
 		return -1;
 	dev = cdev->dev;
 
-	size = min((loff_t)count, resource_size(&dev->resource[0]) - offset);
+	size = min((resource_size_t)count,
+			resource_size(&dev->resource[0]) -
+			(resource_size_t)offset);
 	memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
 	return size;
 }
@@ -1540,7 +1542,9 @@ ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offse
 		return -1;
 	dev = cdev->dev;
 
-	size = min((loff_t)count, resource_size(&dev->resource[0]) - offset);
+	size = min((resource_size_t)count,
+			resource_size(&dev->resource[0]) -
+			(resource_size_t)offset);
 	memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
 	return size;
 }
-- 
1.7.12


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] fs: fs.c fix cast
  2012-09-11  5:31 [PATCH] fs: fs.c fix cast Alexander Aring
@ 2012-09-11  7:20 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2012-09-11  7:20 UTC (permalink / raw)
  To: Alexander Aring; +Cc: barebox

On Tue, Sep 11, 2012 at 07:31:31AM +0200, Alexander Aring wrote:
> Fix casting on min argument, to avoid warnings on 64bit build.
> 
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>

Applied, thanks

Sascha

> ---
>  fs/fs.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/fs.c b/fs/fs.c
> index 38917bf..db4621a 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -1525,7 +1525,9 @@ ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, loff_t offset, ulon
>  		return -1;
>  	dev = cdev->dev;
>  
> -	size = min((loff_t)count, resource_size(&dev->resource[0]) - offset);
> +	size = min((resource_size_t)count,
> +			resource_size(&dev->resource[0]) -
> +			(resource_size_t)offset);
>  	memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
>  	return size;
>  }
> @@ -1540,7 +1542,9 @@ ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, loff_t offse
>  		return -1;
>  	dev = cdev->dev;
>  
> -	size = min((loff_t)count, resource_size(&dev->resource[0]) - offset);
> +	size = min((resource_size_t)count,
> +			resource_size(&dev->resource[0]) -
> +			(resource_size_t)offset);
>  	memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
>  	return size;
>  }
> -- 
> 1.7.12
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-09-11  7:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11  5:31 [PATCH] fs: fs.c fix cast Alexander Aring
2012-09-11  7:20 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox