[PATCH 5/5] Use size_t for memory offsets

Loïc Minier loic.minier at linaro.org
Thu Oct 13 18:06:41 EDT 2011


mem_read() and mem_write() did arithmetic with a local ulong size
variable, a size_t count and an ulong offset to return a ssize_t result.
Change them to use size_t for size and offset and stop casting count to
ulong.

This fixes a warning when building for 64-bits.

This change might have impact on the exported symbols.

Signed-off-by: Loïc Minier <loic.minier at linaro.org>
---
 fs/fs.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/fs.c b/fs/fs.c
index 7d65ec8..0cb226d 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -1038,31 +1038,31 @@ static void memcpy_sz(void *_dst, const void *_src, ulong count, ulong rwsize)
 	}
 }
 
-ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, ulong offset, ulong flags)
+ssize_t mem_read(struct cdev *cdev, void *buf, size_t count, size_t offset, ulong flags)
 {
-	ulong size;
+	size_t size;
 	struct device_d *dev;
 
 	if (!cdev->dev || cdev->dev->num_resources < 1)
 		return -1;
 	dev = cdev->dev;
 
-	size = min((ulong)count, dev->resource[0].size - offset);
+	size = min(count, (size_t)dev->resource[0].size - offset);
 	memcpy_sz(buf, dev_get_mem_region(dev, 0) + offset, size, flags & O_RWSIZE_MASK);
 	return size;
 }
 EXPORT_SYMBOL(mem_read);
 
-ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, ulong offset, ulong flags)
+ssize_t mem_write(struct cdev *cdev, const void *buf, size_t count, size_t offset, ulong flags)
 {
-	ulong size;
+	size_t size;
 	struct device_d *dev;
 
 	if (!cdev->dev || cdev->dev->num_resources < 1)
 		return -1;
 	dev = cdev->dev;
 
-	size = min((ulong)count, dev->resource[0].size - offset);
+	size = min(count, (size_t)dev->resource[0].size - offset);
 	memcpy_sz(dev_get_mem_region(dev, 0) + offset, buf, size, flags & O_RWSIZE_MASK);
 	return size;
 }
-- 
1.7.5.4




More information about the barebox mailing list