lkml.org 
[lkml]   [2008]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] mtd: mtdchar.c silence sparse warning
On Wed, May 14, 2008 at 06:38:37PM -0700, Andrew Morton wrote:
> > - if (copy_to_user(&((struct mtd_oob_buf *)argp)->length,
> > + if (copy_to_user(argp + offsetof(struct mtd_oob_buf, length),
> > &retlen, sizeof(buf.length)))
> > ret = -EFAULT;
>
> Cleaner would be:
>
> struct mtd_oob_buf __user *user_mtd_oob_buf = argp;
>
> if (copy_to_user(&user_mtd_oob_buf->length, ...

Yup. BTW, &((type __user *)p)->field) would work just fine too, but yeah,
local variable like that would be cleaner.


\
 
 \ /
  Last update: 2008-05-15 03:49    [W:0.044 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site