Re: [PATCH 00/16] mm: prepare for converting vm->vm_flags to 64-bit

From: Konstantin Khlebnikov
Date: Thu Mar 22 2012 - 18:24:33 EST


Konstantin Khlebnikov wrote:
Andrew Morton wrote:
On Thu, 22 Mar 2012 21:28:11 +0000
Al Viro<viro@xxxxxxxxxxxxxxxxxx> wrote:

On Thu, Mar 22, 2012 at 02:26:47PM -0700, Andrew Morton wrote:
It would be nice to find some way of triggering compiler warnings or
sparse warnings if someone mixes a 32-bit type with a vm_flags_t. Any
thoughts on this?

(Maybe that's what __nocast does, but Documentation/sparse.txt doesn't
describe it)

Use __bitwise for that - check how gfp_t is handled.

So what does __nocast do?

Actually it forbid any non-forced casts, but its implementation in sparse seems buggy:
__nocast generates some strange false positives. For example it sometimes forgot about
type attributes in function arguments, I saw this for vm_flags argument in ksm_madvise().
I can reproduce this bug, if somebody interested.


1.c:

# define __nocast __attribute__((nocast))

typedef long __nocast long_t;

static void f(long_t *x)
{
}

static void g(void)
{
long_t x;

f(&x);
}

$ sparse 1.c
1.c:13:12: warning: incorrect type in argument 1 (different modifiers)
1.c:13:12: expected int [nocast] [usertype] *x
1.c:13:12: got int *<noident>
1.c:13:12: warning: implicit cast to nocast type

Is this ok?

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