Messages in this thread | | | Date | Thu, 15 May 2008 02:46:00 +0100 | From | Al Viro <> | Subject | Re: [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.
| |