Subject: Re: linux-next: Tree for October 2: percpu compile warnings (i386)

From: Randy Dunlap <[email-masked]>
Date: Fri, 2 Oct 2009 09:40:30 -0700

mm/percpu.c:1873: warning: comparison of distinct pointer types lacks a cast
mm/percpu.c:1879: warning: format '%lx' expects type 'long unsigned int', but argument 2 has type 'size_t'

The second one is easily fixed (s/%lx/%zu/), but is that the correct fix?

The first one is a max(size_t, unsigned long).
The C99 spec says that the max value of a size_t is:
	limit of size_t
	SIZE_MAX 65535
(from 7.8.13(2)), but max_distance (the size_t here) is being compared to
unsigned long base_offset, which isn't limited to 65535 AFAICT.

In fact, this test:
	if (max_distance > (VMALLOC_END - VMALLOC_START) * 3 / 4) {
checks max_distance > 0x000017ff_ffffffff (on x86_64).

And it looks to me like there is some potential for some value truncation
in the max() operation, even if size_t is not limited to SIZE_MAX.

So maybe the size_t(s) should be changed to unsigned long and the
printk format doesn't need to be fixed... ?

---
~Randy