"sparse" warnings..

Linus Torvalds torvalds at osdl.org
Mon May 3 12:11:49 EST 2004

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.

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'

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.

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.

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


** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/

More information about the Linuxppc64-dev mailing list