mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Loïc Minier" <loic.minier@linaro.org>
To: barebox@lists.infradead.org
Subject: [PATCH 5/5] Use size_t for memory offsets
Date: Fri, 14 Oct 2011 00:06:41 +0200	[thread overview]
Message-ID: <1318543601-20819-6-git-send-email-loic.minier@linaro.org> (raw)
In-Reply-To: <1318543601-20819-1-git-send-email-loic.minier@linaro.org>

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


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

  parent reply	other threads:[~2011-10-13 22:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 22:06 [RFC] Fix misc warnings when building sandbox on 64-bits Loïc Minier
2011-10-13 22:06 ` [PATCH 1/5] Only pass -P to cpp when generating ld scripts Loïc Minier
2011-10-13 22:06 ` [PATCH 2/5] Avoid warnings by using format(__printf__) Loïc Minier
2011-10-14  6:50   ` Sascha Hauer
2011-10-13 22:06 ` [PATCH 3/5] fprintf() returns an int Loïc Minier
2011-10-14  7:04   ` Sascha Hauer
2011-10-13 22:06 ` [PATCH 4/5] Use %p in format for pointers Loïc Minier
2011-10-14  7:18   ` Sascha Hauer
2011-10-14  7:22     ` Sascha Hauer
2011-10-13 22:06 ` Loïc Minier [this message]
2011-10-14  7:20   ` [PATCH 5/5] Use size_t for memory offsets Sascha Hauer
2011-10-14  8:59     ` Loïc Minier
2011-10-14 12:11       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1318543601-20819-6-git-send-email-loic.minier@linaro.org \
    --to=loic.minier@linaro.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox