"sparse" warnings..
Benjamin Herrenschmidt
benh at kernel.crashing.org
Mon May 3 13:05:39 EST 2004
On Mon, 2004-05-03 at 12:11, Linus Torvalds wrote:
> Ok, having made "sparse" be somewhat more amenable to cross-compiling (ie
> understanding that the target might be 64-bit, even though it itself is
> running in 32-bit mode), I'm starting to find things in the ppc64 tree
> that sparse really doesn't like.
Heh, cool. I should try it.
> Much of it is just sparse being anal about implicit type conversions,
> notably constants that convert to a bigger size. But some of it seems to
> be due to real bugs in the ppc64 tree:
>
> warning: include/asm/thread_info.h:72:5: undefined preprocessor identifier 'PAGE_SIZE'
> warning: include/asm/thread_info.h:72:23: undefined preprocessor identifier 'PAGE_SIZE'
Interesting. We should probably include page.h in there.
> Lookie there - it's comparing something that isn't defined. It so happens
> that it works (when PAGE_SIZE isn't defined, the preprocessor arithmetic
> rules means that it gets evaluated as zero), but it works for all the
> wrong reasons.
Indeed.
> Most of the warnings are of the type
>
> warning: include/linux/mm.h:365:9: value is so big it is unsigned long
> warning: include/linux/mm.h:527:9: value is so big it is unsigned long
>
> because the "__va()" macro on ppc64 uses KERNELBASE, which in turn is
> defined to PAGE_OFFSET, which in turn is
>
> #define PAGE_OFFSET 0xC000000000000000
>
> which silently makes the constant be of type "unsigned long" through the C
> type expansion rules. Sparse doesn't like that, because most people don't
> actually understand the C type expansion rules.
Well, do you want to explicitely write it with ULL suffix ?
> Quiz: what's the difference between
>
> #define MIN_INT 0x80000000
> #define MIN_INT 2147483648
>
> in C for a 64-bit compiler? Hint: one is "unsigned int", the other is
> "long".
First one gets zero extended, second one gets sign extended I suppose,
this first on is bogus.
Where do I get sparse ? There's a bk ? FAQ ?
Ben.
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list