[MTD] mtdchar.c silence sparse warning

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jul 11 13:59:01 EDT 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=5f6928378b165c4b0d57a711e1c1eb925ad33846
Commit:     5f6928378b165c4b0d57a711e1c1eb925ad33846
Parent:     72289824423655e67993c25c91a7a86a34917209
Author:     Harvey Harrison <harvey.harrison at gmail.com>
AuthorDate: Thu Jul 3 23:40:13 2008 -0700
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 11 14:46:22 2008 +0100

    [MTD] mtdchar.c silence sparse warning
    
    The copy_to_user was casting away the address space to get the offset of
    the length member.  Use offsetof() instead and add it to the void __user
    *argp.
    
    drivers/mtd/mtdchar.c:527:23: warning: cast removes address space of expression
    drivers/mtd/mtdchar.c:527:23: warning: incorrect type in argument 1 (different address spaces)
    drivers/mtd/mtdchar.c:527:23:    expected void [noderef] <asn:1>*to
    drivers/mtd/mtdchar.c:527:23:    got unsigned int *<noident>
    
    Signed-off-by: Harvey Harrison <harvey.harrison at gmail.com>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/mtdchar.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 4b3156f..5fc2c42 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -479,6 +479,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
 	{
 		struct mtd_oob_buf buf;
 		struct mtd_oob_ops ops;
+		struct mtd_oob_buf __user *user_buf = argp;
 	        uint32_t retlen;
 
 		if(!(file->f_mode & 2))
@@ -522,8 +523,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
 		if (ops.oobretlen > 0xFFFFFFFFU)
 			ret = -EOVERFLOW;
 		retlen = ops.oobretlen;
-		if (copy_to_user(&((struct mtd_oob_buf *)argp)->length,
-				 &retlen, sizeof(buf.length)))
+		if (copy_to_user(&user_buf->length, &retlen, sizeof(buf.length)))
 			ret = -EFAULT;
 
 		kfree(ops.oobbuf);



More information about the linux-mtd-cvs mailing list