From patchwork Thu Oct 13 22:06:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: loic.minier@linaro.org X-Patchwork-Id: 4676 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 81C0A23DEE for ; Fri, 14 Oct 2011 09:58:55 +0000 (UTC) Received: from mail-gx0-f180.google.com (mail-gx0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 50A60A18781 for ; Fri, 14 Oct 2011 09:58:55 +0000 (UTC) Received: by mail-gx0-f180.google.com with SMTP id i2so1365420ggn.11 for ; Fri, 14 Oct 2011 02:58:55 -0700 (PDT) Received: by 10.223.60.73 with SMTP id o9mr3116841fah.18.1318586334818; Fri, 14 Oct 2011 02:58:54 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.24.41 with SMTP id r9cs8247laf; Fri, 14 Oct 2011 02:58:54 -0700 (PDT) Received: by 10.227.157.149 with SMTP id b21mr2546296wbx.95.1318586333556; Fri, 14 Oct 2011 02:58:53 -0700 (PDT) Received: from pig2.dooz.org (pig2.dooz.org. [88.191.118.219]) by mx.google.com with ESMTPS id fh14si5564644wbb.8.2011.10.14.02.58.53 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Oct 2011 02:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of lool@dooz.org designates 88.191.118.219 as permitted sender) client-ip=88.191.118.219; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lool@dooz.org designates 88.191.118.219 as permitted sender) smtp.mail=lool@dooz.org Received: from bee.dooz.org (unknown [IPv6:2a01:e35:8a6e:5e80:224:7eff:fe14:65c3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bee.dooz.org", Issuer "dooz.org CA" (verified OK)) by pig2.dooz.org (Postfix) with ESMTPS id 1271FC08A7 for ; Fri, 14 Oct 2011 11:58:53 +0200 (CEST) Received: by bee.dooz.org (Postfix, from userid 1000) id 526822F2C; Fri, 14 Oct 2011 11:58:51 +0200 (CEST) Resent-From: =?iso-8859-1?Q?Lo=EFc?= Minier Resent-Date: Fri, 14 Oct 2011 11:58:51 +0200 Resent-Message-ID: <20111014095851.GH27642@bee.dooz.org> Resent-To: patches@linaro.org X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-26) on pig.dooz.org X-Spam-Level: X-Spam-Status: No, score=-102.6 required=3.0 tests=BAYES_00, USER_IN_WHITELIST autolearn=disabled version=3.1.4 X-Original-To: lool@dooz.org Received: from mail-wy0-f179.google.com (mail-wy0-f179.google.com [74.125.82.179]) by pig.dooz.org (Postfix) with ESMTP id 2D7CC4C0B0 for ; Fri, 14 Oct 2011 00:06:53 +0200 (CEST) Received: by mail-wy0-f179.google.com with SMTP id 36so3087291wyg.24 for ; Thu, 13 Oct 2011 15:06:53 -0700 (PDT) Received: by 10.216.229.86 with SMTP id g64mr582082weq.42.1318543612970; Thu, 13 Oct 2011 15:06:52 -0700 (PDT) X-Forwarded-To: lool@dooz.org X-X-Forwarded-For: loic.minier@linaro.org lool@dooz.org Received: by 10.180.105.167 with SMTP id gn7cs168671wib; Thu, 13 Oct 2011 15:06:52 -0700 (PDT) Received: by 10.204.139.85 with SMTP id d21mr4594001bku.15.1318543611775; Thu, 13 Oct 2011 15:06:51 -0700 (PDT) Received: from pig2.dooz.org (pig2.dooz.org. [88.191.118.219]) by mx.google.com with ESMTPS id j2si3757694bke.3.2011.10.13.15.06.51 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Oct 2011 15:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of lool@bee.dooz.org designates 88.191.118.219 as permitted sender) client-ip=88.191.118.219; Received: from bee.dooz.org (unknown [IPv6:2a01:e35:8a6e:5e80:224:7eff:fe14:65c3]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bee.dooz.org", Issuer "dooz.org CA" (verified OK)) by pig2.dooz.org (Postfix) with ESMTPS id 39A4AC076B; Fri, 14 Oct 2011 00:06:51 +0200 (CEST) Received: by bee.dooz.org (Postfix, from userid 1000) id 4B29D3991; Fri, 14 Oct 2011 00:06:50 +0200 (CEST) From: =?UTF-8?q?Lo=C3=AFc=20Minier?= To: barebox@lists.infradead.org Cc: =?UTF-8?q?Lo=C3=AFc=20Minier?= Subject: [PATCH 5/5] Use size_t for memory offsets Date: Fri, 14 Oct 2011 00:06:41 +0200 Message-Id: <1318543601-20819-6-git-send-email-loic.minier@linaro.org> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1318543601-20819-1-git-send-email-loic.minier@linaro.org> References: <1318543601-20819-1-git-send-email-loic.minier@linaro.org> MIME-Version: 1.0 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 --- 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; }