Re: [PATCH 1/2] mtd: mtdchar.c silence sparse warning

From: Al Viro
Date: Wed May 14 2008 - 21:46:21 EST


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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/