On Sat, 15 Jan 2005, Linus Torvalds wrote:
> 
> You can fix it by hiding the pointer, the same way we do RELOC_HIDE() in
> <linux/compiler-gcc.h>. For basically the same reasons - gcc does 
> something similar for static symbols only.

The empty asm trick (asm("")) may be a bit of an overkill, btw. There are
alternatives. Sparse may be pretty good at doign CSE etc these days, which
is why doing various syntactic changes (casts and offsets in different
places) doesn't help one whit, but it's still all very much local.

So to take your example:

        struct big
        {
                long a;
                long b;
        };

        struct big fun(long a)
        {
                struct big *p = (struct big *) &a;
                return *p;
        }

you can also add an extra level of indirection, and do

        struct big {
                long a;
                long b;
        };

        struct big fun2(struct big *p)
        {
                return *p;
        }

        struct big fun(long a)
        {
                return fun2((struct big *)&a);
        }

and sparse won't complain, because now the violation is no longer locally 
visible.

Of course, if you make "fun2()" be inline, now sparse will see the illegal 
access again, so..

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to