[PATCH] staging: lirc: Fix sparse warnings

Dan Carpenter dan.carpenter at oracle.com
Thu May 8 10:30:28 UTC 2014


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 at iki.fi>

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



More information about the devel mailing list