WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Clean up internal libxc functions to take 'const char *'

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Clean up internal libxc functions to take 'const char *'
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 09 Mar 2006 15:22:07 +0000
Delivery-date: Thu, 09 Mar 2006 15:22:58 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID a1fcee3b2abe44e6cece13a91f1bf012008bf2b0
# Parent  899532500ada24763c01ad27f781701d8240be3a
Clean up internal libxc functions to take 'const char *'
parameters where possible, to avoid unnecessary casts.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_hvm_build.c        Thu Mar  9 13:35:36 2006
@@ -623,7 +623,7 @@
 int xc_hvm_build_mem(int xc_handle,
                      uint32_t domid,
                      int memsize,
-                     char *image_buffer,
+                     const char *image_buffer,
                      unsigned long image_size,
                      unsigned int vcpus,
                      unsigned int pae,
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_linux_build.c
--- a/tools/libxc/xc_linux_build.c      Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_linux_build.c      Thu Mar  9 13:35:36 2006
@@ -117,7 +117,7 @@
     return -EINVAL;
 }
 
-static int probeimageformat(char *image,
+static int probeimageformat(const char *image,
                             unsigned long image_size,
                             struct load_funcs *load_funcs)
 {
@@ -407,7 +407,7 @@
 static int setup_guest(int xc_handle,
                        uint32_t dom,
                        const char *image, unsigned long image_size,
-                       char *initrd, unsigned long initrd_len,
+                       const char *initrd, unsigned long initrd_len,
                        unsigned long nr_pages,
                        unsigned long *pvsi, unsigned long *pvke,
                        unsigned long *pvss, vcpu_guest_context_t *ctxt,
@@ -541,7 +541,7 @@
 static int setup_guest(int xc_handle,
                        uint32_t dom,
                        const char *image, unsigned long image_size,
-                       char *initrd, unsigned long initrd_len,
+                       const char *initrd, unsigned long initrd_len,
                        unsigned long nr_pages,
                        unsigned long *pvsi, unsigned long *pvke,
                        unsigned long *pvss, vcpu_guest_context_t *ctxt,
@@ -586,13 +586,13 @@
     unsigned long shadow_mode_enabled;
     uint32_t supported_features[XENFEAT_NR_SUBMAPS] = { 0, };
 
-    rc = probeimageformat((char *)image, (unsigned long)image_size, 
&load_funcs);
+    rc = probeimageformat(image, image_size, &load_funcs);
     if ( rc != 0 )
         goto error_out;
 
     memset(&dsi, 0, sizeof(struct domain_setup_info));
 
-    rc = (load_funcs.parseimage)((char *)image, (unsigned long)image_size, 
&dsi);
+    rc = (load_funcs.parseimage)(image, image_size, &dsi);
     if ( rc != 0 )
         goto error_out;
 
@@ -700,7 +700,7 @@
         goto error_out;
     }
 
-    (load_funcs.loadimage)((char *)image, image_size,
+    (load_funcs.loadimage)(image, image_size,
                            xc_handle, dom, page_array,
                            &dsi);
 
@@ -959,7 +959,7 @@
 
 static int xc_linux_build_internal(int xc_handle,
                                    uint32_t domid,
-                                   const char *image,
+                                   char *image,
                                    unsigned long image_size,
                                    char *initrd,
                                    unsigned long initrd_len,
@@ -1119,9 +1119,9 @@
 
 int xc_linux_build_mem(int xc_handle,
                        uint32_t domid,
-                       char *image_buffer,
+                       const char *image_buffer,
                        unsigned long image_size,
-                       char *initrd,
+                       const char *initrd,
                        unsigned long initrd_len,
                        const char *cmdline,
                        const char *features,
@@ -1165,7 +1165,7 @@
     }
     else
     {
-        ram_buf = initrd;
+        ram_buf = (char *)initrd;
         ram_len = initrd_len;
     }
 
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_load_aout9.c
--- a/tools/libxc/xc_load_aout9.c       Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_load_aout9.c       Thu Mar  9 13:35:36 2006
@@ -12,20 +12,19 @@
 #error "Unsupported architecture"
 #endif
 
-
 #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
 #define KZERO             0x80000000
 #define KOFFSET(_p)       ((_p)&~KZERO)
 
-static int parseaout9image(char *, unsigned long, struct domain_setup_info *);
-static int loadaout9image(char *, unsigned long, int, uint32_t, unsigned long 
*, struct domain_setup_info *);
-static void copyout(int, uint32_t, unsigned long *, unsigned long, void *, 
int);
-struct Exec *get_header(char *, unsigned long, struct Exec *);
+static int parseaout9image(const char *, unsigned long, struct 
domain_setup_info *);
+static int loadaout9image(const char *, unsigned long, int, uint32_t, unsigned 
long *, struct domain_setup_info *);
+static void copyout(int, uint32_t, unsigned long *, unsigned long, const char 
*, int);
+struct Exec *get_header(const char *, unsigned long, struct Exec *);
 
 
 int 
 probe_aout9(
-    char *image,
+    const char *image,
     unsigned long image_size,
     struct load_funcs *load_funcs)
 {
@@ -43,7 +42,7 @@
 
 static int 
 parseaout9image(
-    char *image,
+    const char *image,
     unsigned long image_size,
     struct domain_setup_info *dsi)
 {
@@ -77,7 +76,7 @@
 
 static int 
 loadaout9image(
-    char *image,
+    const char *image,
     unsigned long image_size,
     int xch, uint32_t dom,
     unsigned long *parray,
@@ -111,7 +110,7 @@
     int xch, uint32_t dom,
     unsigned long *parray,
     unsigned long addr,
-    void *buf,
+    const char *buf,
     int sz)
 {
     unsigned long pgoff, chunksz, off;
@@ -143,7 +142,7 @@
  */
 struct Exec *
 get_header(
-    char *image,
+    const char *image,
     unsigned long image_size,
     struct Exec *ehdr)
 {
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_load_bin.c
--- a/tools/libxc/xc_load_bin.c Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_load_bin.c Thu Mar  9 13:35:36 2006
@@ -99,23 +99,22 @@
 #define FLAGS_REQUIRED XEN_REACTOS_FLAG_ADDRSVALID
 
 static struct xen_bin_image_table *
-findtable(char *image, unsigned long image_size);
+findtable(const char *image, unsigned long image_size);
 static int
 parsebinimage(
-    char *image, unsigned long image_size, struct domain_setup_info *dsi);
+    const char *image, unsigned long image_size,
+    struct domain_setup_info *dsi);
 static int
 loadbinimage(
-    char *image, unsigned long image_size, int xch, uint32_t dom,
+    const char *image, unsigned long image_size, int xch, uint32_t dom,
     unsigned long *parray, struct domain_setup_info *dsi);
 
-int probe_bin(char *image,
+int probe_bin(const char *image,
               unsigned long image_size,
               struct load_funcs *load_funcs)
 {
-    if ( NULL == findtable(image, image_size) )
-    {
-        return -EINVAL;
-    }
+    if ( findtable(image, image_size) == NULL )
+        return -EINVAL;
 
     load_funcs->parseimage = parsebinimage;
     load_funcs->loadimage = loadbinimage;
@@ -124,7 +123,7 @@
 }
 
 static struct xen_bin_image_table *
-findtable(char *image, unsigned long image_size)
+findtable(const char *image, unsigned long image_size)
 {
     struct xen_bin_image_table *table;
     unsigned long *probe_ptr;
@@ -133,15 +132,12 @@
 
     /* Don't go outside the image */
     if ( image_size < sizeof(struct xen_bin_image_table) )
-    {
         return NULL;
-    }
+
     probe_count = image_size;
     /* Restrict to first 8k */
-    if ( 8192 < probe_count )
-    {
+    if ( probe_count > 8192 )
         probe_count = 8192;
-    }
     probe_count = (probe_count - sizeof(struct xen_bin_image_table)) /
                   sizeof(unsigned long);
 
@@ -165,7 +161,7 @@
     return NULL;
 }
 
-static int parsebinimage(char *image, 
+static int parsebinimage(const char *image, 
                          unsigned long image_size,
                          struct domain_setup_info *dsi)
 {
@@ -238,7 +234,7 @@
 
 static int
 loadbinimage(
-    char *image, unsigned long image_size, int xch, uint32_t dom,
+    const char *image, unsigned long image_size, int xch, uint32_t dom,
     unsigned long *parray, struct domain_setup_info *dsi)
 {
     unsigned long size;
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_load_elf.c
--- a/tools/libxc/xc_load_elf.c Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_load_elf.c Thu Mar  9 13:35:36 2006
@@ -19,26 +19,25 @@
 
 static int
 parseelfimage(
-    char *image, unsigned long image_size, struct domain_setup_info *dsi);
+    const char *image, unsigned long image_size,
+    struct domain_setup_info *dsi);
 static int
 loadelfimage(
-    char *image, unsigned long image_size, int xch, uint32_t dom,
+    const char *image, unsigned long image_size, int xch, uint32_t dom,
     unsigned long *parray, struct domain_setup_info *dsi);
 static int
 loadelfsymtab(
-    char *image, int xch, uint32_t dom, unsigned long *parray,
+    const char *image, int xch, uint32_t dom, unsigned long *parray,
     struct domain_setup_info *dsi);
 
-int probe_elf(char *image,
+int probe_elf(const char *image,
               unsigned long image_size,
               struct load_funcs *load_funcs)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
 
     if ( !IS_ELF(*ehdr) )
-    {
-        return -EINVAL;
-    }
+        return -EINVAL;
 
     load_funcs->parseimage = parseelfimage;
     load_funcs->loadimage = loadelfimage;
@@ -52,7 +51,7 @@
             ((phdr->p_flags & (PF_W|PF_X)) != 0));
 }
 
-static int parseelfimage(char *image, 
+static int parseelfimage(const char *image, 
                          unsigned long elfsize,
                          struct domain_setup_info *dsi)
 {
@@ -60,7 +59,8 @@
     Elf_Phdr *phdr;
     Elf_Shdr *shdr;
     unsigned long kernstart = ~0UL, kernend=0UL;
-    char *shstrtab, *guestinfo=NULL, *p;
+    const char *shstrtab;
+    char *guestinfo=NULL, *p;
     int h;
 
     if ( !IS_ELF(*ehdr) )
@@ -98,7 +98,7 @@
         if ( strcmp(&shstrtab[shdr->sh_name], "__xen_guest") != 0 )
             continue;
 
-        guestinfo = image + shdr->sh_offset;
+        guestinfo = (char *)image + shdr->sh_offset;
 
         if ( (strstr(guestinfo, "LOADER=generic") == NULL) &&
              (strstr(guestinfo, "GUEST_OS=linux") == NULL) )
@@ -171,7 +171,7 @@
 
 static int
 loadelfimage(
-    char *image, unsigned long elfsize, int xch, uint32_t dom,
+    const char *image, unsigned long elfsize, int xch, uint32_t dom,
     unsigned long *parray, struct domain_setup_info *dsi)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image;
@@ -222,7 +222,7 @@
 
 static int
 loadelfsymtab(
-    char *image, int xch, uint32_t dom, unsigned long *parray,
+    const char *image, int xch, uint32_t dom, unsigned long *parray,
     struct domain_setup_info *dsi)
 {
     Elf_Ehdr *ehdr = (Elf_Ehdr *)image, *sym_ehdr;
@@ -271,8 +271,9 @@
              (shdr[h].sh_type == SHT_SYMTAB) )
         {
             if ( parray != NULL )
-                xc_map_memcpy(maxva, image + shdr[h].sh_offset, 
shdr[h].sh_size,
-                           xch, dom, parray, dsi->v_start);
+                xc_map_memcpy(maxva, image + shdr[h].sh_offset,
+                              shdr[h].sh_size,
+                              xch, dom, parray, dsi->v_start);
 
             /* Mangled to be based on ELF header location. */
             shdr[h].sh_offset = maxva - dsi->symtab_addr;
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xc_private.c  Thu Mar  9 13:35:36 2006
@@ -364,7 +364,7 @@
 int xc_copy_to_domain_page(int xc_handle,
                            uint32_t domid,
                            unsigned long dst_pfn, 
-                           void *src_page)
+                           const char *src_page)
 {
     void *vaddr = xc_map_foreign_range(
         xc_handle, domid, PAGE_SIZE, PROT_WRITE, dst_pfn);
@@ -410,7 +410,7 @@
     return sz;
 }
 
-void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
+void xc_map_memcpy(unsigned long dst, const char *src, unsigned long size,
                    int xch, uint32_t dom, unsigned long *parray,
                    unsigned long vstart)
 {
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h     Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xenctrl.h     Thu Mar  9 13:35:36 2006
@@ -467,7 +467,7 @@
                          unsigned int start_page, unsigned int nr_pages);
 
 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
-                          unsigned long dst_pfn, void *src_page);
+                          unsigned long dst_pfn, const char *src_page);
 
 int xc_clear_domain_page(int xc_handle, uint32_t domid,
                          unsigned long dst_pfn);
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xenguest.h
--- a/tools/libxc/xenguest.h    Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xenguest.h    Thu Mar  9 13:35:36 2006
@@ -90,9 +90,9 @@
  */
 int xc_linux_build_mem(int xc_handle,
                        uint32_t domid,
-                       char *image_buffer,
+                       const char *image_buffer,
                        unsigned long image_size,
-                       char *initrd_buffer,
+                       const char *initrd_buffer,
                        unsigned long initrd_size,
                        const char *cmdline,
                        const char *features,
@@ -116,7 +116,7 @@
 int xc_hvm_build_mem(int xc_handle,
                      uint32_t domid,
                      int memsize,
-                     char *image_buffer,
+                     const char *image_buffer,
                      unsigned long image_size,
                      unsigned int vcpus,
                      unsigned int pae,
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xg_private.c
--- a/tools/libxc/xg_private.c  Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xg_private.c  Thu Mar  9 13:35:36 2006
@@ -60,7 +60,7 @@
     return image;
 }
 
-char *xc_inflate_buffer(char *in_buf, unsigned long in_size,
+char *xc_inflate_buffer(const char *in_buf, unsigned long in_size,
                         unsigned long *out_size)
 {
     int           sts;
@@ -74,7 +74,7 @@
     {
         if ( out_size != NULL )
             *out_size = in_size;
-        return in_buf;
+        return (char *)in_buf;
     }
 
     out_len = in_buf[in_size-4] +
diff -r 899532500ada -r a1fcee3b2abe tools/libxc/xg_private.h
--- a/tools/libxc/xg_private.h  Thu Mar  9 12:00:38 2006
+++ b/tools/libxc/xg_private.h  Thu Mar  9 13:35:36 2006
@@ -27,7 +27,7 @@
 
 
 char *xc_read_image(const char *filename, unsigned long *size);
-char *xc_inflate_buffer(char *in_buf,
+char *xc_inflate_buffer(const char *in_buf,
                         unsigned long in_size,
                         unsigned long *out_size);
 
@@ -145,9 +145,10 @@
     char *xen_guest_string;
 };
 
-typedef int (*parseimagefunc)(char *image, unsigned long image_size,
+typedef int (*parseimagefunc)(const char *image, unsigned long image_size,
                               struct domain_setup_info *dsi);
-typedef int (*loadimagefunc)(char *image, unsigned long image_size, int xch,
+typedef int (*loadimagefunc)(const char *image, unsigned long image_size,
+                             int xch,
                              uint32_t dom, unsigned long *parray,
                              struct domain_setup_info *dsi);
 
@@ -171,11 +172,11 @@
 } mfn_mapper_t;
 
 int xc_copy_to_domain_page(int xc_handle, uint32_t domid,
-                            unsigned long dst_pfn, void *src_page);
+                            unsigned long dst_pfn, const char *src_page);
 
 unsigned long xc_get_filesz(int fd);
 
-void xc_map_memcpy(unsigned long dst, char *src, unsigned long size,
+void xc_map_memcpy(unsigned long dst, const char *src, unsigned long size,
                    int xch, uint32_t dom, unsigned long *parray,
                    unsigned long vstart);
 
@@ -183,9 +184,12 @@
               domid_t dom);
 
 /* image loading */
-int probe_elf(char *image, unsigned long image_size, struct load_funcs *funcs);
-int probe_bin(char *image, unsigned long image_size, struct load_funcs *funcs);
-int probe_aout9(char *image, unsigned long image_size, struct load_funcs 
*funcs);
+int probe_elf(const char *image, unsigned long image_size,
+              struct load_funcs *funcs);
+int probe_bin(const char *image, unsigned long image_size,
+              struct load_funcs *funcs);
+int probe_aout9(const char *image, unsigned long image_size,
+                struct load_funcs *funcs);
 
 #endif
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Clean up internal libxc functions to take 'const char *', Xen patchbot -unstable <=