Re: [PATCH] staging: lirc: Fix sparse warnings

From: Dan Carpenter
Date: Thu May 08 2014 - 06:30:55 EST


On Thu, May 08, 2014 at 01:11:48PM +0300, Tuomas Tynkkynen wrote:
> Fix sparse warnings by adding __user and __iomem annotations where
> necessary and removing certain unnecessary casts.
>
> Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@xxxxxx>

This patch adds spaces between the cast and the variable. There
shouldn't be a cast. That rule is so people remember that casting is a
high precedence operation.

Joe recently added a check for cast spacing to ./scripts/checkpatch.pl
--strict. Run your patch through ./scripts/checkpatch.pl --strict and
fix the warnings.

> @@ -470,36 +471,36 @@ static long lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arg)
>
> switch (cmd) {
> case LIRC_GET_FEATURES:
> - result = put_user(features, (__u32 *) arg);
> + result = put_user(features, (__u32 __user *) arg);

arg is alway a u32 __user pointer. Do this at the start of the
function.

u32 __user *uptr = (u32 __user *)arg;

Then replace all the "arg" references with "uptr". Btw, the difference
between __u32 and u32 is that __u32 is for code which is shared with
user space and u32 is only allowed in kernel code.

regards,
dan carpenter

--
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/