All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: Hans Verkuil <hverkuil@xs4all.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Sparse Mailing-list <linux-sparse@vger.kernel.org>,
	Linux Media Mailing List <linux-media@vger.kernel.org>,
	Christopher Li <sparse@chrisli.org>
Subject: Re: [PATCH] Fix _IOC_TYPECHECK sparse error
Date: Tue, 1 Apr 2014 07:28:53 -0700	[thread overview]
Message-ID: <20140401142852.GA22576@leaf> (raw)
In-Reply-To: <533A64EC.2090106@xs4all.nl>

On Tue, Apr 01, 2014 at 09:04:12AM +0200, Hans Verkuil wrote:
> When running sparse over drivers/media/v4l2-core/v4l2-ioctl.c I get these
> errors:
> 
> drivers/media/v4l2-core/v4l2-ioctl.c:2043:9: error: bad integer constant expression
> drivers/media/v4l2-core/v4l2-ioctl.c:2044:9: error: bad integer constant expression
> drivers/media/v4l2-core/v4l2-ioctl.c:2045:9: error: bad integer constant expression
> drivers/media/v4l2-core/v4l2-ioctl.c:2046:9: error: bad integer constant expression
> 
> etc.
> 
> The root cause of that turns out to be in include/asm-generic/ioctl.h:
> 
> #include <uapi/asm-generic/ioctl.h>
> 
> /* provoke compile error for invalid uses of size argument */
> extern unsigned int __invalid_size_argument_for_IOC;
> #define _IOC_TYPECHECK(t) \
>         ((sizeof(t) == sizeof(t[1]) && \
>           sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
>           sizeof(t) : __invalid_size_argument_for_IOC)
> 
> If it is defined as this (as is already done if __KERNEL__ is not defined):
> 
> #define _IOC_TYPECHECK(t) (sizeof(t))
> 
> then all is well with the world.
> 
> This patch allows sparse to work correctly.
> 
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

Reviewed-by: Josh Triplett <josh@joshtriplett.org>

> diff --git a/include/asm-generic/ioctl.h b/include/asm-generic/ioctl.h
> index d17295b..297fb0d 100644
> --- a/include/asm-generic/ioctl.h
> +++ b/include/asm-generic/ioctl.h
> @@ -3,10 +3,15 @@
>  
>  #include <uapi/asm-generic/ioctl.h>
>  
> +#ifdef __CHECKER__
> +#define _IOC_TYPECHECK(t) (sizeof(t))
> +#else
>  /* provoke compile error for invalid uses of size argument */
>  extern unsigned int __invalid_size_argument_for_IOC;
>  #define _IOC_TYPECHECK(t) \
>  	((sizeof(t) == sizeof(t[1]) && \
>  	  sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
>  	  sizeof(t) : __invalid_size_argument_for_IOC)
> +#endif
> +
>  #endif /* _ASM_GENERIC_IOCTL_H */
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-04-01 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-01  7:04 [PATCH] Fix _IOC_TYPECHECK sparse error Hans Verkuil
2014-04-01 14:28 ` Josh Triplett [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-05-09  7:43 Hans Verkuil
2014-05-09 20:59 ` Andrew Morton
2014-05-12 13:17   ` Hans Verkuil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140401142852.GA22576@leaf \
    --to=josh@joshtriplett.org \
    --cc=hverkuil@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.