From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Christoph Egger" Subject: [PATCH] Add -Wcast-qual flag Date: Thu, 21 Dec 2006 11:05:20 +0100 Message-ID: <200612211105.21248.Christoph.Egger@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary-00=_hxliFNnOS1CKj1I" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --Boundary-00=_hxliFNnOS1CKj1I Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! The xen-cast.diff adds the -Wcast-qual flag. The xen-cast-xen.diff makes the hypervisor itself buildable with the new flag - at least on x86_32 and x86_64. The xen-cast-tools.diff makes the tools build with the new flag. Generally, the places with the __UNCONST() hack should be considered to be reworked. These places may hide bugs. Christoph --Boundary-00=_hxliFNnOS1CKj1I Content-Type: text/x-diff; charset=us-ascii; name=xen-cast.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=xen-cast.diff diff -r f58b0c778b90 Config.mk --- a/Config.mk Wed Dec 20 15:22:46 2006 +0000 +++ b/Config.mk Thu Dec 21 10:22:56 2006 +0100 @@ -39,7 +39,7 @@ endif CFLAGS += -std=gnu99 -CFLAGS += -Wall -Wstrict-prototypes +CFLAGS += -Wall -Wstrict-prototypes -Wcast-qual # -Wunused-value makes GCC 4.x too aggressive for my taste: ignoring the # result of any casted expression causes a warning. --Boundary-00=_hxliFNnOS1CKj1I Content-Type: text/x-diff; charset=us-ascii; name=xen-cast-xen.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=xen-cast-xen.diff diff -r f58b0c778b90 xen/arch/x86/domain_build.c --- a/xen/arch/x86/domain_build.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/arch/x86/domain_build.c Thu Dec 21 10:34:37 2006 +0100 @@ -55,12 +55,12 @@ static long dom0_nrpages, dom0_min_nrpag * If +ve: The specified amount is an absolute value. * If -ve: The specified amount is subtracted from total available memory. */ -static long parse_amt(char *s, char **ps) +static long parse_amt(const char *s, const char **ps) { long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT; return (*s == '-') ? -pages : pages; } -static void parse_dom0_mem(char *s) +static void parse_dom0_mem(const char *s) { do { if ( !strncmp(s, "min:", 4) ) @@ -152,7 +152,8 @@ static void process_dom0_ioports_disable static void process_dom0_ioports_disable(void) { unsigned long io_from, io_to; - char *t, *u, *s = opt_dom0_ioports_disable; + char *t, *s = opt_dom0_ioports_disable; + const char *u; if ( *s == '\0' ) return; @@ -892,7 +893,7 @@ int construct_dom0(struct domain *d, return 0; } -int elf_sanity_check(Elf_Ehdr *ehdr) +int elf_sanity_check(const Elf_Ehdr *ehdr) { if ( !IS_ELF(*ehdr) || #if defined(__i386__) diff -r f58b0c778b90 xen/arch/x86/hvm/platform.c --- a/xen/arch/x86/hvm/platform.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/arch/x86/hvm/platform.c Thu Dec 21 10:34:37 2006 +0100 @@ -1153,7 +1153,8 @@ unsigned long copy_to_user_hvm(void *to, return 0; } - return hvm_copy_to_guest_virt((unsigned long)to, (void *)from, len); +#define __UNCONST(x) (void *)(unsigned long)(x) + return hvm_copy_to_guest_virt((unsigned long)to, __UNCONST(from), len); } unsigned long copy_from_user_hvm(void *to, const void *from, unsigned len) diff -r f58b0c778b90 xen/arch/x86/time.c --- a/xen/arch/x86/time.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/arch/x86/time.c Thu Dec 21 10:34:37 2006 +0100 @@ -41,7 +41,7 @@ unsigned long cpu_khz; /* CPU clock fre unsigned long cpu_khz; /* CPU clock frequency in kHz. */ unsigned long hpet_address; DEFINE_SPINLOCK(rtc_lock); -unsigned long volatile jiffies; +volatile unsigned long jiffies; static u32 wc_sec, wc_nsec; /* UTC time at last 'time update'. */ static DEFINE_SPINLOCK(wc_lock); @@ -148,7 +148,7 @@ void timer_interrupt(int irq, void *dev_ ASSERT(local_irq_is_enabled()); /* Update jiffies counter. */ - (*(unsigned long *)&jiffies)++; + (*(volatile unsigned long *)&jiffies)++; /* Rough hack to allow accurate timers to sort-of-work with no APIC. */ if ( !cpu_has_apic ) diff -r f58b0c778b90 xen/common/elf.c --- a/xen/common/elf.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/elf.c Thu Dec 21 10:34:38 2006 +0100 @@ -16,7 +16,7 @@ #include static void loadelfsymtab(struct domain_setup_info *dsi, int doload); -static inline int is_loadable_phdr(Elf_Phdr *phdr) +static inline int is_loadable_phdr(const Elf_Phdr *phdr) { return ((phdr->p_type == PT_LOAD) && ((phdr->p_flags & (PF_W|PF_X)) != 0)); @@ -26,7 +26,7 @@ static inline int is_loadable_phdr(Elf_P * Fallback for kernels containing only the legacy __xen_guest string * and no ELF notes. */ -static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab) +static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab) { return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0; } @@ -102,19 +102,19 @@ static unsigned long long xen_guest_nume /* * Interface to the Xen ELF notes. */ -#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_))) +#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_))) #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3)) #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3)) -static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr) -{ - Elf_Note *note; +static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr) +{ + const Elf_Note *note; if ( shdr->sh_type != SHT_NOTE ) return 0; - for ( note = (Elf_Note *)(image + shdr->sh_offset); - note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); + for ( note = (const Elf_Note *)(image + shdr->sh_offset); + note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); note = ELFNOTE_NEXT(note) ) { if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) ) @@ -124,15 +124,15 @@ static int is_xen_elfnote_section(const return 0; } -static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type) -{ - Elf_Note *note; +static const Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type) +{ + const Elf_Note *note; if ( !dsi->__elfnote_section ) return NULL; - for ( note = (Elf_Note *)dsi->__elfnote_section; - note < (Elf_Note *)dsi->__elfnote_section_end; + for ( note = (const Elf_Note *)dsi->__elfnote_section; + note < (const Elf_Note *)dsi->__elfnote_section_end; note = ELFNOTE_NEXT(note) ) { if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) ) @@ -147,7 +147,7 @@ static Elf_Note *xen_elfnote_lookup(stru const char *xen_elfnote_string(struct domain_setup_info *dsi, int type) { - Elf_Note *note; + const Elf_Note *note; if ( !dsi->__elfnote_section ) return xen_guest_string(dsi, type); @@ -162,7 +162,7 @@ unsigned long long xen_elfnote_numeric(s unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi, int type, int *defined) { - Elf_Note *note; + const Elf_Note *note; *defined = 0; @@ -179,10 +179,10 @@ unsigned long long xen_elfnote_numeric(s { case 4: *defined = 1; - return *(uint32_t*)ELFNOTE_DESC(note); + return *(const uint32_t*)ELFNOTE_DESC(note); case 8: *defined = 1; - return *(uint64_t*)ELFNOTE_DESC(note); + return *(const uint64_t*)ELFNOTE_DESC(note); default: printk("ERROR: unknown data size %#x for numeric type note %#x\n", note->descsz, type); @@ -192,9 +192,9 @@ unsigned long long xen_elfnote_numeric(s int parseelfimage(struct domain_setup_info *dsi) { - Elf_Ehdr *ehdr = (Elf_Ehdr *)dsi->image_addr; - Elf_Phdr *phdr; - Elf_Shdr *shdr; + const Elf_Ehdr *ehdr = (const Elf_Ehdr *)dsi->image_addr; + const Elf_Phdr *phdr; + const Elf_Shdr *shdr; Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry; const char *shstrtab, *p; const char *image = (char *)dsi->image_addr; @@ -222,12 +222,12 @@ int parseelfimage(struct domain_setup_in /* Look for .notes segment containing at least one Xen note */ for ( h = 0; h < ehdr->e_shnum; h++ ) { - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); if ( !is_xen_elfnote_section(image, shdr) ) continue; - dsi->__elfnote_section = (void *)image + shdr->sh_offset; + dsi->__elfnote_section = (const void *)image + shdr->sh_offset; dsi->__elfnote_section_end = - (void *)image + shdr->sh_offset + shdr->sh_size; + (const void *)image + shdr->sh_offset + shdr->sh_size; break; } @@ -240,16 +240,16 @@ int parseelfimage(struct domain_setup_in printk("ELF image has no section-header strings table.\n"); return -EINVAL; } - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (ehdr->e_shstrndx*ehdr->e_shentsize)); shstrtab = image + shdr->sh_offset; for ( h = 0; h < ehdr->e_shnum; h++ ) { - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); if ( is_xen_guest_section(shdr, shstrtab) ) { - dsi->__xen_guest_string = (char *)image + shdr->sh_offset; + dsi->__xen_guest_string = (const char *)image + shdr->sh_offset; break; } } @@ -346,7 +346,7 @@ int parseelfimage(struct domain_setup_in for ( h = 0; h < ehdr->e_phnum; h++ ) { - phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); + phdr = (const Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); if ( !is_loadable_phdr(phdr) ) continue; vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start; diff -r f58b0c778b90 xen/common/kernel.c --- a/xen/common/kernel.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/kernel.c Thu Dec 21 10:34:38 2006 +0100 @@ -20,7 +20,8 @@ int tainted; void cmdline_parse(char *cmdline) { - char opt[100], *optval, *p = cmdline, *q; + char opt[100], *optval, *q; + const char *p = cmdline; struct kernel_param *param; if ( p == NULL ) @@ -70,13 +71,13 @@ void cmdline_parse(char *cmdline) break; case OPT_UINT: *(unsigned int *)param->var = - simple_strtol(optval, (char **)&optval, 0); + simple_strtol(optval, (const char **)&optval, 0); break; case OPT_BOOL: *(int *)param->var = 1; break; case OPT_CUSTOM: - ((void (*)(char *))param->var)(optval); + ((void (*)(const char *))param->var)(optval); break; } } diff -r f58b0c778b90 xen/common/kexec.c --- a/xen/common/kexec.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/kexec.c Thu Dec 21 10:34:38 2006 +0100 @@ -37,7 +37,7 @@ spinlock_t kexec_lock = SPIN_LOCK_UNLOCK xen_kexec_reserve_t kexec_crash_area; -static void __init parse_crashkernel(char *str) +static void __init parse_crashkernel(const char *str) { unsigned long start, size; diff -r f58b0c778b90 xen/common/lib.c --- a/xen/common/lib.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/lib.c Thu Dec 21 10:34:38 2006 +0100 @@ -439,11 +439,14 @@ s64 __moddi3(s64 a, s64 b) #endif /* BITS_PER_LONG == 32 */ -unsigned long long parse_size_and_unit(const char *s, char **ps) -{ - unsigned long long ret = simple_strtoull(s, (char **)&s, 0); - - switch (*s) { +unsigned long long parse_size_and_unit(const char *s, const char **ps) +{ + unsigned long long ret; + const char *s1; + + ret = simple_strtoull(s, &s1, 0); + + switch (*s1) { case 'G': case 'g': ret <<= 10; case 'M': case 'm': @@ -459,7 +462,7 @@ unsigned long long parse_size_and_unit(c } if (ps != NULL) - *ps = (char *)s; + *ps = s1; return ret; } diff -r f58b0c778b90 xen/common/page_alloc.c --- a/xen/common/page_alloc.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/page_alloc.c Thu Dec 21 10:34:38 2006 +0100 @@ -197,7 +197,7 @@ void init_boot_pages(paddr_t ps, paddr_t void init_boot_pages(paddr_t ps, paddr_t pe) { unsigned long bad_spfn, bad_epfn, i; - char *p; + const char *p; ps = round_pgup(ps); pe = round_pgdown(pe); @@ -586,7 +586,7 @@ void *alloc_xenheap_pages(unsigned int o } -void free_xenheap_pages(void *v, unsigned int order) +void free_xenheap_pages(const void *v, unsigned int order) { unsigned long flags; diff -r f58b0c778b90 xen/common/string.c --- a/xen/common/string.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/string.c Thu Dec 21 10:34:38 2006 +0100 @@ -7,6 +7,8 @@ #include #include #include + +#define __UNCONST(x) (void *)(unsigned long)(x) #ifndef __HAVE_ARCH_STRNICMP /** @@ -204,7 +206,7 @@ char * strchr(const char * s, int c) for(; *s != (char) c; ++s) if (*s == '\0') return NULL; - return (char *) s; + return __UNCONST(s); } #endif @@ -219,7 +221,7 @@ char * strrchr(const char * s, int c) const char *p = s + strlen(s); do { if (*p == (char)c) - return (char *)p; + return __UNCONST(p); } while (--p >= s); return NULL; } @@ -296,7 +298,7 @@ char * strpbrk(const char * cs,const cha for( sc1 = cs; *sc1 != '\0'; ++sc1) { for( sc2 = ct; *sc2 != '\0'; ++sc2) { if (*sc1 == *sc2) - return (char *) sc1; + return __UNCONST(sc1); } } return NULL; @@ -481,12 +483,12 @@ char * strstr(const char * s1,const char l2 = strlen(s2); if (!l2) - return (char *) s1; + return __UNCONST(s1); l1 = strlen(s1); while (l1 >= l2) { l1--; if (!memcmp(s1,s2,l2)) - return (char *) s1; + return __UNCONST(s1); s1++; } return NULL; @@ -508,7 +510,7 @@ void *memchr(const void *s, int c, size_ const unsigned char *p = s; while (n-- != 0) { if ((unsigned char)c == *p++) { - return (void *)(p-1); + return __UNCONST(p-1); } } return NULL; diff -r f58b0c778b90 xen/common/time.c --- a/xen/common/time.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/time.c Thu Dec 21 10:34:38 2006 +0100 @@ -40,7 +40,7 @@ struct tm gmtime(unsigned long t) struct tm tbuf; long days, rem; int y; - unsigned short int *ip; + const unsigned short int *ip; days = t / SECS_PER_DAY; rem = t % SECS_PER_DAY; @@ -66,7 +66,7 @@ struct tm gmtime(unsigned long t) } tbuf.tm_year = y - 1900; tbuf.tm_yday = days; - ip = (unsigned short int *)__mon_lengths[__isleap(y)]; + ip = (const unsigned short int *)__mon_lengths[__isleap(y)]; for ( y = 0; days >= ip[y]; ++y ) days -= ip[y]; tbuf.tm_mon = y; diff -r f58b0c778b90 xen/common/vsprintf.c --- a/xen/common/vsprintf.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/vsprintf.c Thu Dec 21 10:34:38 2006 +0100 @@ -28,7 +28,7 @@ * @endp: A pointer to the end of the parsed string will be placed here * @base: The number base to use */ -unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) +unsigned long simple_strtoul(const char *cp,const char **endp,unsigned int base) { unsigned long result = 0,value; @@ -52,7 +52,7 @@ unsigned long simple_strtoul(const char cp++; } if (endp) - *endp = (char *)cp; + *endp = cp; return result; } @@ -64,7 +64,7 @@ EXPORT_SYMBOL(simple_strtoul); * @endp: A pointer to the end of the parsed string will be placed here * @base: The number base to use */ -long simple_strtol(const char *cp,char **endp,unsigned int base) +long simple_strtol(const char *cp,const char **endp,unsigned int base) { if(*cp=='-') return -simple_strtoul(cp+1,endp,base); @@ -79,7 +79,7 @@ EXPORT_SYMBOL(simple_strtol); * @endp: A pointer to the end of the parsed string will be placed here * @base: The number base to use */ -unsigned long long simple_strtoull(const char *cp,char **endp,unsigned int base) +unsigned long long simple_strtoull(const char *cp,const char **endp,unsigned int base) { unsigned long long result = 0,value; @@ -103,7 +103,7 @@ unsigned long long simple_strtoull(const cp++; } if (endp) - *endp = (char *)cp; + *endp = cp; return result; } @@ -115,7 +115,7 @@ EXPORT_SYMBOL(simple_strtoull); * @endp: A pointer to the end of the parsed string will be placed here * @base: The number base to use */ -long long simple_strtoll(const char *cp,char **endp,unsigned int base) +long long simple_strtoll(const char *cp,const char **endp,unsigned int base) { if(*cp=='-') return -simple_strtoull(cp+1,endp,base); diff -r f58b0c778b90 xen/common/xmalloc.c --- a/xen/common/xmalloc.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/common/xmalloc.c Thu Dec 21 10:34:38 2006 +0100 @@ -87,7 +87,7 @@ static void *data_from_header(struct xma #endif } -static struct xmalloc_hdr *header_from_data(const void *p) +static struct xmalloc_hdr *header_from_data(void *p) { #if XMALLOC_DEBUG unsigned char *data = (unsigned char *)p - SMP_CACHE_BYTES; @@ -208,7 +208,7 @@ void *_xmalloc(size_t size, size_t align return xmalloc_new_page(size); } -void xfree(const void *p) +void xfree(void *p) { unsigned long flags; struct xmalloc_hdr *i, *tmp, *hdr; diff -r f58b0c778b90 xen/drivers/char/ns16550.c --- a/xen/drivers/char/ns16550.c Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/drivers/char/ns16550.c Thu Dec 21 10:34:38 2006 +0100 @@ -300,7 +300,7 @@ static int parse_parity_char(int c) return; \ } while ( 0 ) -static void ns16550_parse_port_config(struct ns16550 *uart, char *conf) +static void ns16550_parse_port_config(struct ns16550 *uart, const char *conf) { int baud; diff -r f58b0c778b90 xen/include/asm-x86/bitops.h --- a/xen/include/asm-x86/bitops.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/asm-x86/bitops.h Thu Dec 21 10:34:40 2006 +0100 @@ -246,7 +246,7 @@ static __inline__ int constant_test_bit( return ((1U << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0; } -static __inline__ int variable_test_bit(int nr, const volatile void * addr) +static __inline__ int variable_test_bit(int nr, volatile void * addr) { int oldbit; @@ -288,7 +288,7 @@ static inline unsigned int __scanbit(uns */ #define find_first_bit(addr,size) \ ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - (__scanbit(*(unsigned long *)addr)) : \ + (__scanbit(*(const unsigned long *)addr)) : \ __find_first_bit(addr,size))) /** @@ -299,7 +299,7 @@ static inline unsigned int __scanbit(uns */ #define find_next_bit(addr,size,off) \ ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - ((off) + (__scanbit((*(unsigned long *)addr) >> (off)))) : \ + ((off) + (__scanbit((*(const unsigned long *)addr) >> (off)))) : \ __find_next_bit(addr,size,off))) /** @@ -312,7 +312,7 @@ static inline unsigned int __scanbit(uns */ #define find_first_zero_bit(addr,size) \ ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - (__scanbit(~*(unsigned long *)addr)) : \ + (__scanbit(~*(const unsigned long *)addr)) : \ __find_first_zero_bit(addr,size))) /** @@ -323,7 +323,7 @@ static inline unsigned int __scanbit(uns */ #define find_next_zero_bit(addr,size,off) \ ((__builtin_constant_p(size) && (size) <= BITS_PER_LONG ? \ - ((off)+(__scanbit(~(((*(unsigned long *)addr)) >> (off))))) : \ + ((off)+(__scanbit(~(((*(const unsigned long *)addr)) >> (off))))) : \ __find_next_zero_bit(addr,size,off))) diff -r f58b0c778b90 xen/include/asm-x86/system.h --- a/xen/include/asm-x86/system.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/asm-x86/system.h Thu Dec 21 10:34:40 2006 +0100 @@ -19,7 +19,7 @@ #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) struct __xchg_dummy { unsigned long a[100]; }; -#define __xg(x) ((struct __xchg_dummy *)(x)) +#define __xg(x) ((volatile struct __xchg_dummy *)(x)) /* diff -r f58b0c778b90 xen/include/asm-x86/uaccess.h --- a/xen/include/asm-x86/uaccess.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/asm-x86/uaccess.h Thu Dec 21 10:34:40 2006 +0100 @@ -140,7 +140,7 @@ extern void __put_user_bad(void); }) struct __large_struct { unsigned long buf[100]; }; -#define __m(x) (*(struct __large_struct *)(x)) +#define __m(x) (*(const struct __large_struct *)(x)) /* * Tell gcc we read from memory instead of writing: this is because @@ -200,16 +200,16 @@ __copy_to_user(void __user *to, const vo switch (n) { case 1: - __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1); + __put_user_size(*(const u8 *)from, (u8 __user *)to, 1, ret, 1); return ret; case 2: - __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2); + __put_user_size(*(const u16 *)from, (u16 __user *)to, 2, ret, 2); return ret; case 4: - __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4); + __put_user_size(*(const u32 *)from, (u32 __user *)to, 4, ret, 4); return ret; case 8: - __put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret, 8); + __put_user_size(*(const u64 *)from, (u64 __user *)to, 8, ret, 8); return ret; } } diff -r f58b0c778b90 xen/include/xen/elf.h --- a/xen/include/xen/elf.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/elf.h Thu Dec 21 10:34:41 2006 +0100 @@ -526,7 +526,7 @@ extern const char *xen_elfnote_string(st extern const char *xen_elfnote_string(struct domain_setup_info *dsi, int type); #ifdef Elf_Ehdr -extern int elf_sanity_check(Elf_Ehdr *ehdr); +extern int elf_sanity_check(const Elf_Ehdr *ehdr); #endif #endif /* __XEN_ELF_H__ */ diff -r f58b0c778b90 xen/include/xen/kernel.h --- a/xen/include/xen/kernel.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/kernel.h Thu Dec 21 10:34:41 2006 +0100 @@ -42,7 +42,7 @@ * */ #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) /* diff -r f58b0c778b90 xen/include/xen/lib.h --- a/xen/include/xen/lib.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/lib.h Thu Dec 21 10:34:41 2006 +0100 @@ -74,15 +74,15 @@ extern int vscnprintf(char *buf, size_t __attribute__ ((format (printf, 3, 0))); long simple_strtol( - const char *cp,char **endp, unsigned int base); + const char *cp,const char **endp, unsigned int base); unsigned long simple_strtoul( - const char *cp,char **endp, unsigned int base); + const char *cp,const char **endp, unsigned int base); long long simple_strtoll( - const char *cp,char **endp, unsigned int base); + const char *cp,const char **endp, unsigned int base); unsigned long long simple_strtoull( - const char *cp,char **endp, unsigned int base); + const char *cp,const char **endp, unsigned int base); -unsigned long long parse_size_and_unit(const char *s, char **ps); +unsigned long long parse_size_and_unit(const char *s, const char **ps); #define TAINT_UNSAFE_SMP (1<<0) #define TAINT_MACHINE_CHECK (1<<1) diff -r f58b0c778b90 xen/include/xen/mm.h --- a/xen/include/xen/mm.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/mm.h Thu Dec 21 10:34:41 2006 +0100 @@ -55,7 +55,7 @@ void scrub_heap_pages(void); /* Xen suballocator. These functions are interrupt-safe. */ void init_xenheap_pages(paddr_t ps, paddr_t pe); void *alloc_xenheap_pages(unsigned int order); -void free_xenheap_pages(void *v, unsigned int order); +void free_xenheap_pages(const void *v, unsigned int order); #define alloc_xenheap_page() (alloc_xenheap_pages(0)) #define free_xenheap_page(v) (free_xenheap_pages(v,0)) diff -r f58b0c778b90 xen/include/xen/sched.h --- a/xen/include/xen/sched.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/sched.h Thu Dec 21 10:34:41 2006 +0100 @@ -202,8 +202,8 @@ struct domain_setup_info * You should use the xen_elfnote_* accessors below in order to * pickup the correct one and retain backwards compatibility. */ - void *__elfnote_section, *__elfnote_section_end; - char *__xen_guest_string; + const void *__elfnote_section, *__elfnote_section_end; + const char *__xen_guest_string; }; extern struct vcpu *idle_vcpu[NR_CPUS]; diff -r f58b0c778b90 xen/include/xen/xmalloc.h --- a/xen/include/xen/xmalloc.h Wed Dec 20 15:22:46 2006 +0000 +++ b/xen/include/xen/xmalloc.h Thu Dec 21 10:34:41 2006 +0100 @@ -12,7 +12,7 @@ #define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES)) /* Free any of the above. */ -extern void xfree(const void *); +extern void xfree(void *); /* Underlying functions */ extern void *_xmalloc(size_t size, size_t align); --Boundary-00=_hxliFNnOS1CKj1I Content-Type: text/x-diff; charset=us-ascii; name=xen-cast-tools.diff Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=xen-cast-tools.diff diff -r f58b0c778b90 tools/blktap/drivers/block-qcow.c --- a/tools/blktap/drivers/block-qcow.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/blktap/drivers/block-qcow.c Thu Dec 21 10:34:27 2006 +0100 @@ -38,6 +38,8 @@ #include "bswap.h" #include "aes.h" #include "tapdisk.h" + +#define __UNCONST(x) (void *)(unsigned long)(x) #if 1 #define ASSERT(_p) \ @@ -759,7 +761,7 @@ static int decompress_buffer(uint8_t *ou memset(strm, 0, sizeof(*strm)); - strm->next_in = (uint8_t *)buf; + strm->next_in = (uint8_t *)__UNCONST(buf); strm->avail_in = buf_size; strm->next_out = out_buf; strm->avail_out = out_buf_size; @@ -1445,7 +1447,7 @@ int qcow_compress_cluster(struct td_stat } strm.avail_in = s->cluster_size; - strm.next_in = (uint8_t *)buf; + strm.next_in = (uint8_t *)__UNCONST(buf); strm.avail_out = s->cluster_size; strm.next_out = out_buf; diff -r f58b0c778b90 tools/libxc/xc_linux_build.c --- a/tools/libxc/xc_linux_build.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xc_linux_build.c Thu Dec 21 10:51:28 2006 +0100 @@ -1079,7 +1079,7 @@ static int xc_linux_build_internal(int x static int xc_linux_build_internal(int xc_handle, uint32_t domid, unsigned int mem_mb, - char *image, + const char *image, unsigned long image_size, struct initrd_info *initrd, const char *cmdline, diff -r f58b0c778b90 tools/libxc/xc_linux_save.c --- a/tools/libxc/xc_linux_save.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xc_linux_save.c Thu Dec 21 10:34:31 2006 +0100 @@ -80,7 +80,7 @@ static xen_pfn_t *live_m2p = NULL; #define BITMAP_SIZE ((max_pfn + BITS_PER_LONG - 1) / 8) #define BITMAP_ENTRY(_nr,_bmap) \ - ((unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG] + ((volatile unsigned long *)(_bmap))[(_nr)/BITS_PER_LONG] #define BITMAP_SHIFT(_nr) ((_nr) % BITS_PER_LONG) @@ -112,7 +112,7 @@ static inline int count_bits ( int nr, v static inline int count_bits ( int nr, volatile void *addr) { int i, count = 0; - unsigned long *p = (unsigned long *)addr; + volatile unsigned long *p = (volatile unsigned long *)addr; /* We know that the array is padded to unsigned long. */ for( i = 0; i < (nr / (sizeof(unsigned long)*8)); i++, p++ ) count += hweight32(*p); @@ -443,7 +443,7 @@ static int canonicalize_pagetable(unsign /* XXX index of the L2 entry in PAE mode which holds the guest LPT */ #define PAE_GLPT_L2ENTRY (495) - pte = ((uint64_t*)spage)[PAE_GLPT_L2ENTRY]; + pte = ((const uint64_t*)spage)[PAE_GLPT_L2ENTRY]; if(((pte >> PAGE_SHIFT) & 0x0fffffff) == live_p2m[pfn]) xen_start = (hvirt_start >> L2_PAGETABLE_SHIFT_PAE) & 0x1ff; @@ -464,9 +464,9 @@ static int canonicalize_pagetable(unsign unsigned long pfn, mfn; if (pt_levels == 2) - pte = ((uint32_t*)spage)[i]; + pte = ((const uint32_t*)spage)[i]; else - pte = ((uint64_t*)spage)[i]; + pte = ((const uint64_t*)spage)[i]; if (i >= xen_start && i < xen_end) pte = 0; diff -r f58b0c778b90 tools/libxc/xc_load_bin.c --- a/tools/libxc/xc_load_bin.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xc_load_bin.c Thu Dec 21 10:34:31 2006 +0100 @@ -98,7 +98,7 @@ struct xen_bin_image_table #define FLAGS_MASK ((~ 0) & (~ XEN_REACTOS_FLAG_ALIGN4K)) #define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID -static struct xen_bin_image_table * +static const struct xen_bin_image_table * findtable(const char *image, unsigned long image_size); static int parsebinimage( @@ -122,11 +122,11 @@ int probe_bin(const char *image, return 0; } -static struct xen_bin_image_table * +static const struct xen_bin_image_table * findtable(const char *image, unsigned long image_size) { - struct xen_bin_image_table *table; - unsigned long *probe_ptr; + const struct xen_bin_image_table *table; + const unsigned long *probe_ptr; unsigned probe_index; unsigned probe_count; @@ -142,13 +142,13 @@ findtable(const char *image, unsigned lo sizeof(unsigned long); /* Search for the magic header */ - probe_ptr = (unsigned long *) image; + probe_ptr = (const unsigned long *) image; table = NULL; for ( probe_index = 0; probe_index < probe_count; probe_index++ ) { if ( XEN_REACTOS_MAGIC3 == *probe_ptr ) { - table = (struct xen_bin_image_table *) probe_ptr; + table = (const struct xen_bin_image_table *) probe_ptr; /* Checksum correct? */ if ( 0 == table->magic + table->flags + table->checksum ) { @@ -165,7 +165,7 @@ static int parsebinimage(const char *ima unsigned long image_size, struct domain_setup_info *dsi) { - struct xen_bin_image_table *image_info; + const struct xen_bin_image_table *image_info; unsigned long start_addr; unsigned long end_addr; @@ -186,13 +186,13 @@ static int parsebinimage(const char *ima /* Sanity check on the addresses */ if ( image_info->header_addr < image_info->load_addr || - ((char *) image_info - image) < + ((const char *) image_info - image) < (image_info->header_addr - image_info->load_addr) ) { ERROR("Invalid header_addr."); return -EINVAL; } - start_addr = image_info->header_addr - ((char *) image_info - image); + start_addr = image_info->header_addr - ((const char *) image_info - image); if ( 0 != image_info->load_end_addr && ( image_info->load_end_addr < image_info->load_end_addr || start_addr + image_size < image_info->load_end_addr ) ) @@ -221,7 +221,7 @@ static int parsebinimage(const char *ima else { dsi->v_end = image_info->load_addr + image_size - - (((char *) image_info - image) - + (((const char *) image_info - image) - (image_info->header_addr - image_info->load_addr)); } dsi->v_kernstart = dsi->v_start; @@ -240,7 +240,7 @@ loadbinimage( unsigned long size; char *va; unsigned long done, chunksz; - struct xen_bin_image_table *image_info; + const struct xen_bin_image_table *image_info; image_info = findtable(image, image_size); if ( NULL == image_info ) @@ -252,7 +252,7 @@ loadbinimage( /* Determine image size */ if ( 0 == image_info->load_end_addr ) { - size = image_size - (((char *) image_info - image) - + size = image_size - (((const char *)image_info - image) - (image_info->header_addr - image_info->load_addr)); } @@ -262,7 +262,7 @@ loadbinimage( } /* It's possible that we need to skip the first part of the image */ - image += ((char *)image_info - image) - + image += ((const char *)image_info - image) - (image_info->header_addr - image_info->load_addr); for ( done = 0; done < size; done += chunksz ) diff -r f58b0c778b90 tools/libxc/xc_load_elf.c --- a/tools/libxc/xc_load_elf.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xc_load_elf.c Thu Dec 21 10:34:31 2006 +0100 @@ -75,7 +75,7 @@ int probe_elf(const char *image, unsigned long image_size, struct load_funcs *load_funcs) { - Elf_Ehdr *ehdr = (Elf_Ehdr *)image; + const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image; if ( !IS_ELF(*ehdr) ) return -EINVAL; @@ -86,7 +86,7 @@ int probe_elf(const char *image, return 0; } -static inline int is_loadable_phdr(Elf_Phdr *phdr) +static inline int is_loadable_phdr(const Elf_Phdr *phdr) { return ((phdr->p_type == PT_LOAD) && ((phdr->p_flags & (PF_W|PF_X)) != 0)); @@ -96,12 +96,12 @@ static inline int is_loadable_phdr(Elf_P * Fallback for kernels containing only the legacy __xen_guest string * and no ELF notes. */ -static int is_xen_guest_section(Elf_Shdr *shdr, const char *shstrtab) +static int is_xen_guest_section(const Elf_Shdr *shdr, const char *shstrtab) { return strcmp(&shstrtab[shdr->sh_name], "__xen_guest") == 0; } -static const char *xen_guest_lookup(struct domain_setup_info *dsi, int type) +static const char *xen_guest_lookup(const struct domain_setup_info *dsi, int type) { const char *xenguest_fallbacks[] = { [XEN_ELFNOTE_ENTRY] = "VIRT_ENTRY=", @@ -134,7 +134,7 @@ static const char *xen_guest_lookup(stru return p + strlen(fallback); } -static const char *xen_guest_string(struct domain_setup_info *dsi, int type) +static const char *xen_guest_string(const struct domain_setup_info *dsi, int type) { const char *p = xen_guest_lookup(dsi, type); @@ -148,7 +148,7 @@ static const char *xen_guest_string(stru return p; } -static unsigned long long xen_guest_numeric(struct domain_setup_info *dsi, +static unsigned long long xen_guest_numeric(const struct domain_setup_info *dsi, int type, int *defined) { const char *p = xen_guest_lookup(dsi, type); @@ -175,19 +175,19 @@ static unsigned long long xen_guest_nume /* * Interface to the Xen ELF notes. */ -#define ELFNOTE_NAME(_n_) ((void*)(_n_) + sizeof(*(_n_))) +#define ELFNOTE_NAME(_n_) ((const void*)(_n_) + sizeof(*(_n_))) #define ELFNOTE_DESC(_n_) (ELFNOTE_NAME(_n_) + (((_n_)->namesz+3)&~3)) #define ELFNOTE_NEXT(_n_) (ELFNOTE_DESC(_n_) + (((_n_)->descsz+3)&~3)) -static int is_xen_elfnote_section(const char *image, Elf_Shdr *shdr) -{ - Elf_Note *note; +static int is_xen_elfnote_section(const char *image, const Elf_Shdr *shdr) +{ + const Elf_Note *note; if ( shdr->sh_type != SHT_NOTE ) return 0; - for ( note = (Elf_Note *)(image + shdr->sh_offset); - note < (Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); + for ( note = (const Elf_Note *)(image + shdr->sh_offset); + note < (const Elf_Note *)(image + shdr->sh_offset + shdr->sh_size); note = ELFNOTE_NEXT(note) ) { if ( !strncmp(ELFNOTE_NAME(note), "Xen", 4) ) @@ -197,15 +197,15 @@ static int is_xen_elfnote_section(const return 0; } -static Elf_Note *xen_elfnote_lookup(struct domain_setup_info *dsi, int type) -{ - Elf_Note *note; +static const Elf_Note *xen_elfnote_lookup(const struct domain_setup_info *dsi, int type) +{ + const Elf_Note *note; if ( !dsi->__elfnote_section ) return NULL; - for ( note = (Elf_Note *)dsi->__elfnote_section; - note < (Elf_Note *)dsi->__elfnote_section_end; + for ( note = (const Elf_Note *)dsi->__elfnote_section; + note < (const Elf_Note *)dsi->__elfnote_section_end; note = ELFNOTE_NEXT(note) ) { if ( strncmp(ELFNOTE_NAME(note), "Xen", 4) ) @@ -218,9 +218,9 @@ static Elf_Note *xen_elfnote_lookup(stru return NULL; } -const char *xen_elfnote_string(struct domain_setup_info *dsi, int type) -{ - Elf_Note *note; +const char *xen_elfnote_string(const struct domain_setup_info *dsi, int type) +{ + const Elf_Note *note; if ( !dsi->__elfnote_section ) return xen_guest_string(dsi, type); @@ -232,10 +232,10 @@ const char *xen_elfnote_string(struct do return (const char *)ELFNOTE_DESC(note); } -unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi, +unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi, int type, int *defined) { - Elf_Note *note; + const Elf_Note *note; *defined = 0; @@ -252,10 +252,10 @@ unsigned long long xen_elfnote_numeric(s { case 4: *defined = 1; - return *(uint32_t*)ELFNOTE_DESC(note); + return *(const uint32_t*)ELFNOTE_DESC(note); case 8: *defined = 1; - return *(uint64_t*)ELFNOTE_DESC(note); + return *(const uint64_t*)ELFNOTE_DESC(note); default: xc_set_error(XC_INVALID_KERNEL, "elfnotes: unknown data size %#x for numeric type note %#x\n", @@ -268,9 +268,9 @@ static int parseelfimage(const char *ima unsigned long image_len, struct domain_setup_info *dsi) { - Elf_Ehdr *ehdr = (Elf_Ehdr *)image; - Elf_Phdr *phdr; - Elf_Shdr *shdr; + const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image; + const Elf_Phdr *phdr; + const Elf_Shdr *shdr; Elf_Addr kernstart = ~0, kernend = 0, vaddr, virt_entry; const char *shstrtab, *p; int h, virt_base_defined, elf_pa_off_defined, virt_entry_defined; @@ -331,12 +331,12 @@ static int parseelfimage(const char *ima /* Look for .notes segment containing at least one Xen note */ for ( h = 0; h < ehdr->e_shnum; h++ ) { - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); if ( !is_xen_elfnote_section(image, shdr) ) continue; - dsi->__elfnote_section = (void *)image + shdr->sh_offset; + dsi->__elfnote_section = (const void *)image + shdr->sh_offset; dsi->__elfnote_section_end = - (void *)image + shdr->sh_offset + shdr->sh_size; + (const void *)image + shdr->sh_offset + shdr->sh_size; break; } @@ -350,16 +350,16 @@ static int parseelfimage(const char *ima "ELF image has no section-header strings table."); return -EINVAL; } - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (ehdr->e_shstrndx*ehdr->e_shentsize)); shstrtab = image + shdr->sh_offset; for ( h = 0; h < ehdr->e_shnum; h++ ) { - shdr = (Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); + shdr = (const Elf_Shdr *)(image + ehdr->e_shoff + (h*ehdr->e_shentsize)); if ( is_xen_guest_section(shdr, shstrtab) ) { - dsi->__xen_guest_string = (char *)image + shdr->sh_offset; + dsi->__xen_guest_string = (const char *)image + shdr->sh_offset; break; } } @@ -462,7 +462,7 @@ static int parseelfimage(const char *ima for ( h = 0; h < ehdr->e_phnum; h++ ) { - phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); + phdr = (const Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); if ( !is_loadable_phdr(phdr) ) continue; vaddr = phdr->p_paddr - dsi->elf_paddr_offset + dsi->v_start; @@ -514,8 +514,8 @@ loadelfimage( const char *image, unsigned long elfsize, int xch, uint32_t dom, xen_pfn_t *parray, struct domain_setup_info *dsi) { - Elf_Ehdr *ehdr = (Elf_Ehdr *)image; - Elf_Phdr *phdr; + const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image; + const Elf_Phdr *phdr; int h; char *va; @@ -523,7 +523,7 @@ loadelfimage( for ( h = 0; h < ehdr->e_phnum; h++ ) { - phdr = (Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); + phdr = (const Elf_Phdr *)(image + ehdr->e_phoff + (h*ehdr->e_phentsize)); if ( !is_loadable_phdr(phdr) ) continue; @@ -569,7 +569,8 @@ loadelfsymtab( const char *image, int xch, uint32_t dom, xen_pfn_t *parray, struct domain_setup_info *dsi) { - Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr; + const Elf_Ehdr *ehdr = (const Elf_Ehdr *)image; + Elf_Ehdr *sym_ehdr; Elf_Shdr *shdr; unsigned long maxva, symva; char *p; diff -r f58b0c778b90 tools/libxc/xg_private.c --- a/tools/libxc/xg_private.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xg_private.c Thu Dec 21 10:54:25 2006 +0100 @@ -11,6 +11,7 @@ #include "xg_private.h" +#define __UNCONST(x) (void *)(unsigned long)(x) int lock_pages(void *addr, size_t len) { int e = 0; @@ -116,7 +117,7 @@ char *xc_inflate_buffer(const char *in_b { if ( out_size != NULL ) *out_size = in_size; - return (char *)in_buf; + return __UNCONST(in_buf); } out_len = (unsigned char)in_buf[in_size-4] + @@ -132,7 +133,7 @@ char *xc_inflate_buffer(const char *in_b return NULL; } - zStream.next_in = (unsigned char *)in_buf; + zStream.next_in = (unsigned char *)__UNCONST(in_buf); zStream.avail_in = in_size; zStream.next_out = (unsigned char *)out_buf; zStream.avail_out = out_len+16; diff -r f58b0c778b90 tools/libxc/xg_private.h --- a/tools/libxc/xg_private.h Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/libxc/xg_private.h Thu Dec 21 10:34:31 2006 +0100 @@ -146,7 +146,7 @@ struct domain_setup_info * You should use the xen_elfnote_* accessors below in order to * pickup the correct one and retain backwards compatibility. */ - void *__elfnote_section, *__elfnote_section_end; + const void *__elfnote_section, *__elfnote_section_end; const char *__xen_guest_string; }; @@ -162,14 +162,14 @@ typedef int (*loadimagefunc)(const char * in the note is returned and *defined is set to non-zero. If no such * note is found then *defined is set to 0 and 0 is returned. */ -extern unsigned long long xen_elfnote_numeric(struct domain_setup_info *dsi, +extern unsigned long long xen_elfnote_numeric(const struct domain_setup_info *dsi, int type, int *defined); /* * If an ELF note of the given type is found then the string contained * in the value is returned, otherwise NULL is returned. */ -extern const char * xen_elfnote_string(struct domain_setup_info *dsi, +extern const char * xen_elfnote_string(const struct domain_setup_info *dsi, int type); struct load_funcs diff -r f58b0c778b90 tools/xenstat/xentop/xentop.c --- a/tools/xenstat/xentop/xentop.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/xenstat/xentop/xentop.c Thu Dec 21 10:34:34 2006 +0100 @@ -269,7 +269,7 @@ static void print(const char *fmt, ...) if (!batch) { if((current_row() < lines()-1)) { va_start(args, fmt); - vwprintw(stdscr, (char *)fmt, args); + vwprintw(stdscr, (const char *)fmt, args); va_end(args); } } else { @@ -283,7 +283,7 @@ static void attr_addstr(int attr, const static void attr_addstr(int attr, const char *str) { attron(attr); - addstr((char *)str); + addstr((const char *)str); attroff(attr); } diff -r f58b0c778b90 tools/xenstore/list.h --- a/tools/xenstore/list.h Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/xenstore/list.h Thu Dec 21 10:34:34 2006 +0100 @@ -12,7 +12,7 @@ #define LIST_POISON2 ((void *) 0x00200200) #define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) /* diff -r f58b0c778b90 tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/xenstore/xenstored_core.c Thu Dec 21 10:34:34 2006 +0100 @@ -53,6 +53,7 @@ #include "hashtable.h" +#define __UNCONST(x) (void *)(unsigned long)(x) extern int xce_handle; /* in xenstored_domain.c */ @@ -417,7 +418,7 @@ static struct node *read_node(struct con struct node *node; TDB_CONTEXT * context = tdb_context(conn); - key.dptr = (void *)name; + key.dptr = (char *)__UNCONST(name); key.dsize = strlen(name); data = tdb_fetch(context, key); @@ -463,7 +464,7 @@ static bool write_node(struct connection TDB_DATA key, data; void *p; - key.dptr = (void *)node->name; + key.dptr = (char *)__UNCONST(node->name); key.dsize = strlen(node->name); data.dsize = 3*sizeof(uint32_t) @@ -736,11 +737,11 @@ char *canonicalize(struct connection *co const char *prefix; if (!node || strstarts(node, "/")) - return (char *)node; + return __UNCONST(node); prefix = get_implicit_path(conn); if (prefix) return talloc_asprintf(node, "%s/%s", prefix, node); - return (char *)node; + return __UNCONST(node); } bool check_event_node(const char *node) @@ -784,7 +785,7 @@ static void delete_node_single(struct co { TDB_DATA key; - key.dptr = (void *)node->name; + key.dptr = (void *)__UNCONST(node->name); key.dsize = strlen(node->name); if (tdb_delete(tdb_context(conn), key) != 0) { @@ -854,7 +855,7 @@ static int destroy_node(void *_node) if (streq(node->name, "/")) corrupt(NULL, "Destroying root node!"); - key.dptr = (void *)node->name; + key.dptr = (void *)__UNCONST(node->name); key.dsize = strlen(node->name); tdb_delete(node->tdb, key); @@ -1446,7 +1447,7 @@ static void manual_node(const char *name node->name = name; node->perms = &perms; node->num_perms = 1; - node->children = (char *)child; + node->children = (char *)__UNCONST(child); if (child) node->childlen = strlen(child) + 1; diff -r f58b0c778b90 tools/xenstore/xs.c --- a/tools/xenstore/xs.c Wed Dec 20 15:22:46 2006 +0000 +++ b/tools/xenstore/xs.c Thu Dec 21 10:34:34 2006 +0100 @@ -77,6 +77,8 @@ struct xs_handle { pthread_mutex_t request_mutex; }; +#define __UNCONST(x) (void *)(unsigned long)(x) + static int read_message(struct xs_handle *h); static void *read_thread(void *arg); @@ -381,7 +383,7 @@ static void *xs_single(struct xs_handle { struct iovec iovec; - iovec.iov_base = (void *)string; + iovec.iov_base = (void *)__UNCONST(string); iovec.iov_len = strlen(string) + 1; return xs_talkv(h, t, type, &iovec, 1, len); } @@ -440,9 +442,9 @@ bool xs_write(struct xs_handle *h, xs_tr { struct iovec iovec[2]; - iovec[0].iov_base = (void *)path; + iovec[0].iov_base = (void *)__UNCONST(path); iovec[0].iov_len = strlen(path) + 1; - iovec[1].iov_base = (void *)data; + iovec[1].iov_base = (void *)__UNCONST(data); iovec[1].iov_len = len; return xs_bool(xs_talkv(h, t, XS_WRITE, iovec, @@ -513,7 +515,7 @@ bool xs_set_permissions(struct xs_handle unsigned int i; struct iovec iov[1+num_perms]; - iov[0].iov_base = (void *)path; + iov[0].iov_base = (void *)__UNCONST(path); iov[0].iov_len = strlen(path) + 1; for (i = 0; i < num_perms; i++) { @@ -561,9 +563,9 @@ bool xs_watch(struct xs_handle *h, const } pthread_mutex_unlock(&h->request_mutex); - iov[0].iov_base = (void *)path; + iov[0].iov_base = (void *)__UNCONST(path); iov[0].iov_len = strlen(path) + 1; - iov[1].iov_base = (void *)token; + iov[1].iov_base = (void *)__UNCONST(token); iov[1].iov_len = strlen(token) + 1; return xs_bool(xs_talkv(h, XBT_NULL, XS_WATCH, iov, @@ -628,9 +630,9 @@ bool xs_unwatch(struct xs_handle *h, con { struct iovec iov[2]; - iov[0].iov_base = (char *)path; + iov[0].iov_base = (char *)__UNCONST(path); iov[0].iov_len = strlen(path) + 1; - iov[1].iov_base = (char *)token; + iov[1].iov_base = (char *)__UNCONST(token); iov[1].iov_len = strlen(token) + 1; return xs_bool(xs_talkv(h, XBT_NULL, XS_UNWATCH, iov, @@ -740,7 +742,7 @@ char *xs_debug_command(struct xs_handle { struct iovec iov[2]; - iov[0].iov_base = (void *)cmd; + iov[0].iov_base = (void *)__UNCONST(cmd); iov[0].iov_len = strlen(cmd) + 1; iov[1].iov_base = data; iov[1].iov_len = len; --Boundary-00=_hxliFNnOS1CKj1I Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --Boundary-00=_hxliFNnOS1CKj1I--