On Thu, Jul 06, 2017 at 11:44:49PM +0200, Christoph Hellwig wrote:
> > Which sparse version are you using and what's your .config?
> 
> sparse is v0.5.0-62-gce18a90, .config is attached.

Arrgh...  OK, I see what's going on.  sparse commit affecting that
is "Allow casting to a restricted type if !restricted_value"; it
allows the things like (__le32)0.  It's present in sparse.git,
but not in chrisl/sparse.git, which is what you are using.

Anyway, the thing I'd missed kernel-side is this:
#define __TYPE_IS_L(t)  (__same_type((t)0, 0L))
#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))

Let's turn them into
#define __TYPE_AS(t, v) __same_type((__force t)0, v) 
#define __TYPE_IS_L(t)  (__TYPE_AS(t, 0L))
#define __TYPE_IS_UL(t) (__TYPE_AS(t, 0UL))
#define __TYPE_IS_LL(t) (__TYPE_AS(t, 0LL) || __TYPE_AS(t, 0ULL))

That should do it both for old and for new versions of sparse.

Reply via email to