ia64/xen-unstable
changeset 9205:a1fcee3b2abe
Clean up internal libxc functions to take 'const char *'
parameters where possible, to avoid unnecessary casts.
Signed-off-by: Keir Fraser <keir@xensource.com>
parameters where possible, to avoid unnecessary casts.
Signed-off-by: Keir Fraser <keir@xensource.com>
author | kaf24@firebug.cl.cam.ac.uk |
---|---|
date | Thu Mar 09 14:35:36 2006 +0100 (2006-03-09) |
parents | 899532500ada |
children | d4a2af362e5e |
files | tools/libxc/xc_hvm_build.c tools/libxc/xc_linux_build.c tools/libxc/xc_load_aout9.c tools/libxc/xc_load_bin.c tools/libxc/xc_load_elf.c tools/libxc/xc_private.c tools/libxc/xenctrl.h tools/libxc/xenguest.h tools/libxc/xg_private.c tools/libxc/xg_private.h |
line diff
1.1 --- a/tools/libxc/xc_hvm_build.c Thu Mar 09 13:00:38 2006 +0100 1.2 +++ b/tools/libxc/xc_hvm_build.c Thu Mar 09 14:35:36 2006 +0100 1.3 @@ -623,7 +623,7 @@ int xc_hvm_build(int xc_handle, 1.4 int xc_hvm_build_mem(int xc_handle, 1.5 uint32_t domid, 1.6 int memsize, 1.7 - char *image_buffer, 1.8 + const char *image_buffer, 1.9 unsigned long image_size, 1.10 unsigned int vcpus, 1.11 unsigned int pae,
2.1 --- a/tools/libxc/xc_linux_build.c Thu Mar 09 13:00:38 2006 +0100 2.2 +++ b/tools/libxc/xc_linux_build.c Thu Mar 09 14:35:36 2006 +0100 2.3 @@ -117,7 +117,7 @@ static int parse_features( 2.4 return -EINVAL; 2.5 } 2.6 2.7 -static int probeimageformat(char *image, 2.8 +static int probeimageformat(const char *image, 2.9 unsigned long image_size, 2.10 struct load_funcs *load_funcs) 2.11 { 2.12 @@ -407,7 +407,7 @@ extern unsigned long xc_ia64_fpsr_defaul 2.13 static int setup_guest(int xc_handle, 2.14 uint32_t dom, 2.15 const char *image, unsigned long image_size, 2.16 - char *initrd, unsigned long initrd_len, 2.17 + const char *initrd, unsigned long initrd_len, 2.18 unsigned long nr_pages, 2.19 unsigned long *pvsi, unsigned long *pvke, 2.20 unsigned long *pvss, vcpu_guest_context_t *ctxt, 2.21 @@ -541,7 +541,7 @@ static int setup_guest(int xc_handle, 2.22 static int setup_guest(int xc_handle, 2.23 uint32_t dom, 2.24 const char *image, unsigned long image_size, 2.25 - char *initrd, unsigned long initrd_len, 2.26 + const char *initrd, unsigned long initrd_len, 2.27 unsigned long nr_pages, 2.28 unsigned long *pvsi, unsigned long *pvke, 2.29 unsigned long *pvss, vcpu_guest_context_t *ctxt, 2.30 @@ -586,13 +586,13 @@ static int setup_guest(int xc_handle, 2.31 unsigned long shadow_mode_enabled; 2.32 uint32_t supported_features[XENFEAT_NR_SUBMAPS] = { 0, }; 2.33 2.34 - rc = probeimageformat((char *)image, (unsigned long)image_size, &load_funcs); 2.35 + rc = probeimageformat(image, image_size, &load_funcs); 2.36 if ( rc != 0 ) 2.37 goto error_out; 2.38 2.39 memset(&dsi, 0, sizeof(struct domain_setup_info)); 2.40 2.41 - rc = (load_funcs.parseimage)((char *)image, (unsigned long)image_size, &dsi); 2.42 + rc = (load_funcs.parseimage)(image, image_size, &dsi); 2.43 if ( rc != 0 ) 2.44 goto error_out; 2.45 2.46 @@ -700,7 +700,7 @@ static int setup_guest(int xc_handle, 2.47 goto error_out; 2.48 } 2.49 2.50 - (load_funcs.loadimage)((char *)image, image_size, 2.51 + (load_funcs.loadimage)(image, image_size, 2.52 xc_handle, dom, page_array, 2.53 &dsi); 2.54 2.55 @@ -959,7 +959,7 @@ static int setup_guest(int xc_handle, 2.56 2.57 static int xc_linux_build_internal(int xc_handle, 2.58 uint32_t domid, 2.59 - const char *image, 2.60 + char *image, 2.61 unsigned long image_size, 2.62 char *initrd, 2.63 unsigned long initrd_len, 2.64 @@ -1119,9 +1119,9 @@ static int xc_linux_build_internal(int x 2.65 2.66 int xc_linux_build_mem(int xc_handle, 2.67 uint32_t domid, 2.68 - char *image_buffer, 2.69 + const char *image_buffer, 2.70 unsigned long image_size, 2.71 - char *initrd, 2.72 + const char *initrd, 2.73 unsigned long initrd_len, 2.74 const char *cmdline, 2.75 const char *features, 2.76 @@ -1165,7 +1165,7 @@ int xc_linux_build_mem(int xc_handle, 2.77 } 2.78 else 2.79 { 2.80 - ram_buf = initrd; 2.81 + ram_buf = (char *)initrd; 2.82 ram_len = initrd_len; 2.83 } 2.84
3.1 --- a/tools/libxc/xc_load_aout9.c Thu Mar 09 13:00:38 2006 +0100 3.2 +++ b/tools/libxc/xc_load_aout9.c Thu Mar 09 14:35:36 2006 +0100 3.3 @@ -12,20 +12,19 @@ 3.4 #error "Unsupported architecture" 3.5 #endif 3.6 3.7 - 3.8 #define round_pgup(_p) (((_p)+(PAGE_SIZE-1))&PAGE_MASK) 3.9 #define KZERO 0x80000000 3.10 #define KOFFSET(_p) ((_p)&~KZERO) 3.11 3.12 -static int parseaout9image(char *, unsigned long, struct domain_setup_info *); 3.13 -static int loadaout9image(char *, unsigned long, int, uint32_t, unsigned long *, struct domain_setup_info *); 3.14 -static void copyout(int, uint32_t, unsigned long *, unsigned long, void *, int); 3.15 -struct Exec *get_header(char *, unsigned long, struct Exec *); 3.16 +static int parseaout9image(const char *, unsigned long, struct domain_setup_info *); 3.17 +static int loadaout9image(const char *, unsigned long, int, uint32_t, unsigned long *, struct domain_setup_info *); 3.18 +static void copyout(int, uint32_t, unsigned long *, unsigned long, const char *, int); 3.19 +struct Exec *get_header(const char *, unsigned long, struct Exec *); 3.20 3.21 3.22 int 3.23 probe_aout9( 3.24 - char *image, 3.25 + const char *image, 3.26 unsigned long image_size, 3.27 struct load_funcs *load_funcs) 3.28 { 3.29 @@ -43,7 +42,7 @@ probe_aout9( 3.30 3.31 static int 3.32 parseaout9image( 3.33 - char *image, 3.34 + const char *image, 3.35 unsigned long image_size, 3.36 struct domain_setup_info *dsi) 3.37 { 3.38 @@ -77,7 +76,7 @@ parseaout9image( 3.39 3.40 static int 3.41 loadaout9image( 3.42 - char *image, 3.43 + const char *image, 3.44 unsigned long image_size, 3.45 int xch, uint32_t dom, 3.46 unsigned long *parray, 3.47 @@ -111,7 +110,7 @@ copyout( 3.48 int xch, uint32_t dom, 3.49 unsigned long *parray, 3.50 unsigned long addr, 3.51 - void *buf, 3.52 + const char *buf, 3.53 int sz) 3.54 { 3.55 unsigned long pgoff, chunksz, off; 3.56 @@ -143,7 +142,7 @@ copyout( 3.57 */ 3.58 struct Exec * 3.59 get_header( 3.60 - char *image, 3.61 + const char *image, 3.62 unsigned long image_size, 3.63 struct Exec *ehdr) 3.64 {
4.1 --- a/tools/libxc/xc_load_bin.c Thu Mar 09 13:00:38 2006 +0100 4.2 +++ b/tools/libxc/xc_load_bin.c Thu Mar 09 14:35:36 2006 +0100 4.3 @@ -99,23 +99,22 @@ struct xen_bin_image_table 4.4 #define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID 4.5 4.6 static struct xen_bin_image_table * 4.7 -findtable(char *image, unsigned long image_size); 4.8 +findtable(const char *image, unsigned long image_size); 4.9 static int 4.10 parsebinimage( 4.11 - char *image, unsigned long image_size, struct domain_setup_info *dsi); 4.12 + const char *image, unsigned long image_size, 4.13 + struct domain_setup_info *dsi); 4.14 static int 4.15 loadbinimage( 4.16 - char *image, unsigned long image_size, int xch, uint32_t dom, 4.17 + const char *image, unsigned long image_size, int xch, uint32_t dom, 4.18 unsigned long *parray, struct domain_setup_info *dsi); 4.19 4.20 -int probe_bin(char *image, 4.21 +int probe_bin(const char *image, 4.22 unsigned long image_size, 4.23 struct load_funcs *load_funcs) 4.24 { 4.25 - if ( NULL == findtable(image, image_size) ) 4.26 - { 4.27 + if ( findtable(image, image_size) == NULL ) 4.28 return -EINVAL; 4.29 - } 4.30 4.31 load_funcs->parseimage = parsebinimage; 4.32 load_funcs->loadimage = loadbinimage; 4.33 @@ -124,7 +123,7 @@ int probe_bin(char *image, 4.34 } 4.35 4.36 static struct xen_bin_image_table * 4.37 -findtable(char *image, unsigned long image_size) 4.38 +findtable(const char *image, unsigned long image_size) 4.39 { 4.40 struct xen_bin_image_table *table; 4.41 unsigned long *probe_ptr; 4.42 @@ -133,15 +132,12 @@ findtable(char *image, unsigned long ima 4.43 4.44 /* Don't go outside the image */ 4.45 if ( image_size < sizeof(struct xen_bin_image_table) ) 4.46 - { 4.47 return NULL; 4.48 - } 4.49 + 4.50 probe_count = image_size; 4.51 /* Restrict to first 8k */ 4.52 - if ( 8192 < probe_count ) 4.53 - { 4.54 + if ( probe_count > 8192 ) 4.55 probe_count = 8192; 4.56 - } 4.57 probe_count = (probe_count - sizeof(struct xen_bin_image_table)) / 4.58 sizeof(unsigned long); 4.59 4.60 @@ -165,7 +161,7 @@ findtable(char *image, unsigned long ima 4.61 return NULL; 4.62 } 4.63 4.64 -static int parsebinimage(char *image, 4.65 +static int parsebinimage(const char *image, 4.66 unsigned long image_size, 4.67 struct domain_setup_info *dsi) 4.68 { 4.69 @@ -238,7 +234,7 @@ static int parsebinimage(char *image, 4.70 4.71 static int 4.72 loadbinimage( 4.73 - char *image, unsigned long image_size, int xch, uint32_t dom, 4.74 + const char *image, unsigned long image_size, int xch, uint32_t dom, 4.75 unsigned long *parray, struct domain_setup_info *dsi) 4.76 { 4.77 unsigned long size;
5.1 --- a/tools/libxc/xc_load_elf.c Thu Mar 09 13:00:38 2006 +0100 5.2 +++ b/tools/libxc/xc_load_elf.c Thu Mar 09 14:35:36 2006 +0100 5.3 @@ -19,26 +19,25 @@ 5.4 5.5 static int 5.6 parseelfimage( 5.7 - char *image, unsigned long image_size, struct domain_setup_info *dsi); 5.8 + const char *image, unsigned long image_size, 5.9 + struct domain_setup_info *dsi); 5.10 static int 5.11 loadelfimage( 5.12 - char *image, unsigned long image_size, int xch, uint32_t dom, 5.13 + const char *image, unsigned long image_size, int xch, uint32_t dom, 5.14 unsigned long *parray, struct domain_setup_info *dsi); 5.15 static int 5.16 loadelfsymtab( 5.17 - char *image, int xch, uint32_t dom, unsigned long *parray, 5.18 + const char *image, int xch, uint32_t dom, unsigned long *parray, 5.19 struct domain_setup_info *dsi); 5.20 5.21 -int probe_elf(char *image, 5.22 +int probe_elf(const char *image, 5.23 unsigned long image_size, 5.24 struct load_funcs *load_funcs) 5.25 { 5.26 Elf_Ehdr *ehdr = (Elf_Ehdr *)image; 5.27 5.28 if ( !IS_ELF(*ehdr) ) 5.29 - { 5.30 return -EINVAL; 5.31 - } 5.32 5.33 load_funcs->parseimage = parseelfimage; 5.34 load_funcs->loadimage = loadelfimage; 5.35 @@ -52,7 +51,7 @@ static inline int is_loadable_phdr(Elf_P 5.36 ((phdr->p_flags & (PF_W|PF_X)) != 0)); 5.37 } 5.38 5.39 -static int parseelfimage(char *image, 5.40 +static int parseelfimage(const char *image, 5.41 unsigned long elfsize, 5.42 struct domain_setup_info *dsi) 5.43 { 5.44 @@ -60,7 +59,8 @@ static int parseelfimage(char *image, 5.45 Elf_Phdr *phdr; 5.46 Elf_Shdr *shdr; 5.47 unsigned long kernstart = ~0UL, kernend=0UL; 5.48 - char *shstrtab, *guestinfo=NULL, *p; 5.49 + const char *shstrtab; 5.50 + char *guestinfo=NULL, *p; 5.51 int h; 5.52 5.53 if ( !IS_ELF(*ehdr) ) 5.54 @@ -98,7 +98,7 @@ static int parseelfimage(char *image, 5.55 if ( strcmp(&shstrtab[shdr->sh_name], "__xen_guest") != 0 ) 5.56 continue; 5.57 5.58 - guestinfo = image + shdr->sh_offset; 5.59 + guestinfo = (char *)image + shdr->sh_offset; 5.60 5.61 if ( (strstr(guestinfo, "LOADER=generic") == NULL) && 5.62 (strstr(guestinfo, "GUEST_OS=linux") == NULL) ) 5.63 @@ -171,7 +171,7 @@ static int parseelfimage(char *image, 5.64 5.65 static int 5.66 loadelfimage( 5.67 - char *image, unsigned long elfsize, int xch, uint32_t dom, 5.68 + const char *image, unsigned long elfsize, int xch, uint32_t dom, 5.69 unsigned long *parray, struct domain_setup_info *dsi) 5.70 { 5.71 Elf_Ehdr *ehdr = (Elf_Ehdr *)image; 5.72 @@ -222,7 +222,7 @@ loadelfimage( 5.73 5.74 static int 5.75 loadelfsymtab( 5.76 - char *image, int xch, uint32_t dom, unsigned long *parray, 5.77 + const char *image, int xch, uint32_t dom, unsigned long *parray, 5.78 struct domain_setup_info *dsi) 5.79 { 5.80 Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr; 5.81 @@ -271,8 +271,9 @@ loadelfsymtab( 5.82 (shdr[h].sh_type == SHT_SYMTAB) ) 5.83 { 5.84 if ( parray != NULL ) 5.85 - xc_map_memcpy(maxva, image + shdr[h].sh_offset, shdr[h].sh_size, 5.86 - xch, dom, parray, dsi->v_start); 5.87 + xc_map_memcpy(maxva, image + shdr[h].sh_offset, 5.88 + shdr[h].sh_size, 5.89 + xch, dom, parray, dsi->v_start); 5.90 5.91 /* Mangled to be based on ELF header location. */ 5.92 shdr[h].sh_offset = maxva - dsi->symtab_addr;
6.1 --- a/tools/libxc/xc_private.c Thu Mar 09 13:00:38 2006 +0100 6.2 +++ b/tools/libxc/xc_private.c Thu Mar 09 14:35:36 2006 +0100 6.3 @@ -364,7 +364,7 @@ long xc_get_tot_pages(int xc_handle, uin 6.4 int xc_copy_to_domain_page(int xc_handle, 6.5 uint32_t domid, 6.6 unsigned long dst_pfn, 6.7 - void *src_page) 6.8 + const char *src_page) 6.9 { 6.10 void *vaddr = xc_map_foreign_range( 6.11 xc_handle, domid, PAGE_SIZE, PROT_WRITE, dst_pfn); 6.12 @@ -410,7 +410,7 @@ unsigned long xc_get_filesz(int fd) 6.13 return sz; 6.14 } 6.15 6.16 -void xc_map_memcpy(unsigned long dst, char *src, unsigned long size, 6.17 +void xc_map_memcpy(unsigned long dst, const char *src, unsigned long size, 6.18 int xch, uint32_t dom, unsigned long *parray, 6.19 unsigned long vstart) 6.20 {
7.1 --- a/tools/libxc/xenctrl.h Thu Mar 09 13:00:38 2006 +0100 7.2 +++ b/tools/libxc/xenctrl.h Thu Mar 09 14:35:36 2006 +0100 7.3 @@ -467,7 +467,7 @@ int xc_ia64_get_pfn_list(int xc_handle, 7.4 unsigned int start_page, unsigned int nr_pages); 7.5 7.6 int xc_copy_to_domain_page(int xc_handle, uint32_t domid, 7.7 - unsigned long dst_pfn, void *src_page); 7.8 + unsigned long dst_pfn, const char *src_page); 7.9 7.10 int xc_clear_domain_page(int xc_handle, uint32_t domid, 7.11 unsigned long dst_pfn);
8.1 --- a/tools/libxc/xenguest.h Thu Mar 09 13:00:38 2006 +0100 8.2 +++ b/tools/libxc/xenguest.h Thu Mar 09 14:35:36 2006 +0100 8.3 @@ -90,9 +90,9 @@ int xc_linux_build(int xc_handle, 8.4 */ 8.5 int xc_linux_build_mem(int xc_handle, 8.6 uint32_t domid, 8.7 - char *image_buffer, 8.8 + const char *image_buffer, 8.9 unsigned long image_size, 8.10 - char *initrd_buffer, 8.11 + const char *initrd_buffer, 8.12 unsigned long initrd_size, 8.13 const char *cmdline, 8.14 const char *features, 8.15 @@ -116,7 +116,7 @@ int xc_hvm_build(int xc_handle, 8.16 int xc_hvm_build_mem(int xc_handle, 8.17 uint32_t domid, 8.18 int memsize, 8.19 - char *image_buffer, 8.20 + const char *image_buffer, 8.21 unsigned long image_size, 8.22 unsigned int vcpus, 8.23 unsigned int pae,
9.1 --- a/tools/libxc/xg_private.c Thu Mar 09 13:00:38 2006 +0100 9.2 +++ b/tools/libxc/xg_private.c Thu Mar 09 14:35:36 2006 +0100 9.3 @@ -60,7 +60,7 @@ char *xc_read_image(const char *filename 9.4 return image; 9.5 } 9.6 9.7 -char *xc_inflate_buffer(char *in_buf, unsigned long in_size, 9.8 +char *xc_inflate_buffer(const char *in_buf, unsigned long in_size, 9.9 unsigned long *out_size) 9.10 { 9.11 int sts; 9.12 @@ -74,7 +74,7 @@ char *xc_inflate_buffer(char *in_buf, un 9.13 { 9.14 if ( out_size != NULL ) 9.15 *out_size = in_size; 9.16 - return in_buf; 9.17 + return (char *)in_buf; 9.18 } 9.19 9.20 out_len = in_buf[in_size-4] +
10.1 --- a/tools/libxc/xg_private.h Thu Mar 09 13:00:38 2006 +0100 10.2 +++ b/tools/libxc/xg_private.h Thu Mar 09 14:35:36 2006 +0100 10.3 @@ -27,7 +27,7 @@ 10.4 10.5 10.6 char *xc_read_image(const char *filename, unsigned long *size); 10.7 -char *xc_inflate_buffer(char *in_buf, 10.8 +char *xc_inflate_buffer(const char *in_buf, 10.9 unsigned long in_size, 10.10 unsigned long *out_size); 10.11 10.12 @@ -145,9 +145,10 @@ struct domain_setup_info 10.13 char *xen_guest_string; 10.14 }; 10.15 10.16 -typedef int (*parseimagefunc)(char *image, unsigned long image_size, 10.17 +typedef int (*parseimagefunc)(const char *image, unsigned long image_size, 10.18 struct domain_setup_info *dsi); 10.19 -typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch, 10.20 +typedef int (*loadimagefunc)(const char *image, unsigned long image_size, 10.21 + int xch, 10.22 uint32_t dom, unsigned long *parray, 10.23 struct domain_setup_info *dsi); 10.24 10.25 @@ -171,11 +172,11 @@ typedef struct mfn_mapper { 10.26 } mfn_mapper_t; 10.27 10.28 int xc_copy_to_domain_page(int xc_handle, uint32_t domid, 10.29 - unsigned long dst_pfn, void *src_page); 10.30 + unsigned long dst_pfn, const char *src_page); 10.31 10.32 unsigned long xc_get_filesz(int fd); 10.33 10.34 -void xc_map_memcpy(unsigned long dst, char *src, unsigned long size, 10.35 +void xc_map_memcpy(unsigned long dst, const char *src, unsigned long size, 10.36 int xch, uint32_t dom, unsigned long *parray, 10.37 unsigned long vstart); 10.38 10.39 @@ -183,9 +184,12 @@ int pin_table(int xc_handle, unsigned in 10.40 domid_t dom); 10.41 10.42 /* image loading */ 10.43 -int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs); 10.44 -int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs); 10.45 -int probe_aout9(char *image, unsigned long image_size, struct load_funcs *funcs); 10.46 +int probe_elf(const char *image, unsigned long image_size, 10.47 + struct load_funcs *funcs); 10.48 +int probe_bin(const char *image, unsigned long image_size, 10.49 + struct load_funcs *funcs); 10.50 +int probe_aout9(const char *image, unsigned long image_size, 10.51 + struct load_funcs *funcs); 10.52 10.53 #endif 10.54