lguest: some sparse fixes.

Doesn't fix any bugs, but reduces sparse complaints.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
---
 drivers/lguest/lg.h          |    2 +-
 drivers/lguest/page_tables.c |   17 +++++++++--------
 include/linux/compiler-gcc.h |    4 ++++
 3 files changed, 14 insertions(+), 9 deletions(-)

diff -r 5954d964c0db drivers/lguest/lg.h
--- a/drivers/lguest/lg.h	Thu Oct 23 15:43:58 2008 +1100
+++ b/drivers/lguest/lg.h	Thu Oct 23 16:49:07 2008 +1100
@@ -18,7 +18,7 @@ int init_pagetables(struct page **switch
 
 struct pgdir
 {
-	pgd_t *gpgdir;
+	pgd_t __user *gpgdir;
 	pgd_t *pgdir;
 };
 
diff -r 5954d964c0db drivers/lguest/page_tables.c
--- a/drivers/lguest/page_tables.c	Thu Oct 23 15:43:58 2008 +1100
+++ b/drivers/lguest/page_tables.c	Thu Oct 23 16:49:07 2008 +1100
@@ -135,7 +135,7 @@ static pte_t *spte_addr(struct lg_cpu *c
 
 /* These two functions just like the above two, except they access the Guest
  * page tables.  Hence they return a Guest address. */
-static pgd_t *gpgd_addr(struct lg_cpu *cpu, unsigned long vaddr)
+static pgd_t __user *gpgd_addr(struct lg_cpu *cpu, unsigned long vaddr)
 {
 	unsigned int index = vaddr >> (PGDIR_SHIFT);
 	return cpu->lg->pgdirs[cpu->cpu_pgd].gpgdir + index;
@@ -560,7 +560,7 @@ static unsigned int find_pgdir(struct lg
  * allocate a new one (and so the kernel parts are not there), we set
  * blank_pgdir. */
 static unsigned int new_pgdir(struct lg_cpu *cpu,
-			      pgd_t *gpgdir,
+			      pgd_t __user *gpgdir,
 			      int *blank_pgdir)
 {
 	unsigned int next;
@@ -623,7 +623,7 @@ void guest_new_pagetable(struct lg_cpu *
 	/* If not, we allocate or mug an existing one: if it's a fresh one,
 	 * repin gets set to 1. */
 	if (newpgdir == ARRAY_SIZE(cpu->lg->pgdirs))
-		newpgdir = new_pgdir(cpu, (pgd_t *)pgtable, &repin);
+		newpgdir = new_pgdir(cpu, (pgd_t __user *)pgtable, &repin);
 	/* Change the current pgd index to the new one. */
 	cpu->cpu_pgd = newpgdir;
 	/* If it was completely blank, we map in the Guest kernel stack */
@@ -846,14 +846,14 @@ static __user pgd_t *setup_pagetables(st
 	linear_pages = (mapped_pages + PTRS_PER_PTE - 1) / PTRS_PER_PTE;
 
 	/* We put the toplevel page directory page at the top of memory. */
-	pgdir = (pgd_t *)(mem + mem_base - initrd_size - PAGE_SIZE);
+	pgdir = (pgd_t __user *)(mem + mem_base - initrd_size - PAGE_SIZE);
 
 	/* Now we use the next linear_pages pages as pte pages */
-	linear = (void *)pgdir - linear_pages * PAGE_SIZE;
+	linear = (void __user *)pgdir - linear_pages * PAGE_SIZE;
 
 #ifdef CONFIG_X86_PAE
 	/* And for PAE, the page before that is used for the pmd page. */
-	pmds = (void *)linear - PAGE_SIZE;
+	pmds = (void __user *)linear - PAGE_SIZE;
 #endif
 
 	/* Linear mapping is easy: put every page's address into the
@@ -876,7 +876,7 @@ static __user pgd_t *setup_pagetables(st
 			return NULL;
 	}
 
-	pgd = __pgd((((u32)pmds) - mem_base) | _PAGE_PRESENT);
+	pgd = __pgd((((unsigned long)pmds) - mem_base) | _PAGE_PRESENT);
 	/* FIXME: This assumes PAGE_OFFSET is 0xC0000000. */
 	if (copy_to_user(&pgdir[0], &pgd, sizeof(pgd))
 	    || copy_to_user(&pgdir[3], &pgd, sizeof(pgd)))
@@ -908,7 +908,8 @@ int init_guest_pagetable(struct lguest *
 {
 	u64 mem;
 	u32 initrd_size;
-	struct boot_params __user *boot = (struct boot_params *)lg->mem_base;
+	struct boot_params __user *boot
+		= (struct boot_params __user *)lg->mem_base;
 
 	/* Get the Guest memory size and the ramdisk size from the boot header
 	 * located at lg->mem_base (Guest address 0). */
diff -r 5954d964c0db include/linux/compiler-gcc.h
--- a/include/linux/compiler-gcc.h	Thu Oct 23 15:43:58 2008 +1100
+++ b/include/linux/compiler-gcc.h	Thu Oct 23 16:49:07 2008 +1100
@@ -25,8 +25,12 @@
     (typeof(ptr)) (__ptr + (off)); })
 
 /* &a[0] degrades to a pointer: a different type from an array */
+#ifdef __CHECKER__
+#define __must_be_array(a) 0
+#else
 #define __must_be_array(a) \
   BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
+#endif
 
 /*
  * Force always-inline if the user requests it so via the .config,
