Fix Char/HChar mixups and constness in m_initimg.
authorflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 3 Nov 2012 19:18:10 +0000 (19:18 +0000)
committerflorian <florian@a5019735-40e9-0310-863c-91ae7b9d1cf9>
Sat, 3 Nov 2012 19:18:10 +0000 (19:18 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13102 a5019735-40e9-0310-863c-91ae7b9d1cf9

coregrind/m_initimg/initimg-darwin.c
coregrind/m_initimg/initimg-linux.c
coregrind/m_initimg/initimg-pathscan.c
coregrind/m_initimg/priv_initimg_pathscan.h

index 5fa13aa1a8175382534163e1fb8800817bc02e8a..64671ab2d75a4160fff382f6c5278cd9dedd9abe 100644 (file)
@@ -62,7 +62,7 @@
 static void load_client ( /*OUT*/ExeInfo* info, 
                           /*OUT*/Addr*    client_ip)
 {
-   HChar* exe_name;
+   const HChar* exe_name;
    Int    ret;
    SysRes res;
 
@@ -116,11 +116,11 @@ static void load_client ( /*OUT*/ExeInfo* info,
 */
 static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
 {
-   HChar* preload_core    = "vgpreload_core";
-   HChar* ld_preload      = "DYLD_INSERT_LIBRARIES=";
-   HChar* dyld_cache      = "DYLD_SHARED_REGION=";
-   HChar* dyld_cache_value= "avoid";
-   HChar* v_launcher      = VALGRIND_LAUNCHER "=";
+   const HChar* preload_core    = "vgpreload_core";
+   const HChar* ld_preload      = "DYLD_INSERT_LIBRARIES=";
+   const HChar* dyld_cache      = "DYLD_SHARED_REGION=";
+   const HChar* dyld_cache_value= "avoid";
+   const HChar* v_launcher      = VALGRIND_LAUNCHER "=";
    Int    ld_preload_len  = VG_(strlen)( ld_preload );
    Int    dyld_cache_len  = VG_(strlen)( dyld_cache );
    Int    v_launcher_len  = VG_(strlen)( v_launcher );
@@ -259,10 +259,10 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
 /*====================================================================*/
 
 /* Add a string onto the string table, and return its address */
-static char *copy_str(char **tab, const char *str)
+static HChar *copy_str(HChar **tab, const HChar *str)
 {
-   char *cp = *tab;
-   char *orig = cp;
+   HChar *cp = *tab;
+   HChar *orig = cp;
 
    while(*str)
       *cp++ = *str++;
@@ -316,14 +316,14 @@ static char *copy_str(char **tab, const char *str)
 
 static 
 Addr setup_client_stack( void*  init_sp,
-                         char** orig_envp, 
+                         HChar** orig_envp, 
                          const ExeInfo* info,
                          Addr   clstack_end,
                          SizeT  clstack_max_size )
 {
-   char **cpp;
-   char *strtab;               /* string table */
-   char *stringbase;
+   HChar **cpp;
+   HChar *strtab;              /* string table */
+   HChar *stringbase;
    Addr *ptr;
    unsigned stringsize;                /* total size of strings in bytes */
    unsigned auxsize;           /* total size of auxv in bytes */
@@ -387,11 +387,11 @@ Addr setup_client_stack( void*  init_sp,
    /* OK, now we know how big the client stack is */
    stacksize =
       sizeof(Word) +                          /* argc */
-      (have_exename ? sizeof(char **) : 0) +  /* argc[0] == exename */
-      sizeof(char **)*argc +                  /* argv */
-      sizeof(char **) +                              /* terminal NULL */
-      sizeof(char **)*envc +                  /* envp */
-      sizeof(char **) +                              /* terminal NULL */
+      (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */
+      sizeof(HChar **)*argc +                 /* argv */
+      sizeof(HChar **) +                      /* terminal NULL */
+      sizeof(HChar **)*envc +                 /* envp */
+      sizeof(HChar **) +                      /* terminal NULL */
       auxsize +                               /* auxv */
       VG_ROUNDUP(stringsize, sizeof(Word));   /* strings (aligned) */
 
@@ -402,7 +402,7 @@ Addr setup_client_stack( void*  init_sp,
    client_SP = VG_ROUNDDN(client_SP, 32); /* make stack 32 byte aligned */
 
    /* base of the string table (aligned) */
-   stringbase = strtab = (char *)clstack_end 
+   stringbase = strtab = (HChar *)clstack_end 
                          - VG_ROUNDUP(stringsize, sizeof(int));
 
    /* The max stack size */
index f4db0b676875e1a65940b009932541bdc848b7d8..2bd219887cae3b60f85dff8a68fb920430b96426 100644 (file)
@@ -71,7 +71,7 @@ static void load_client ( /*OUT*/ExeInfo* info,
                           /*OUT*/Addr*    client_ip,
                          /*OUT*/Addr*    client_toc)
 {
-   HChar* exe_name;
+   const HChar* exe_name;
    Int    ret;
    SysRes res;
 
@@ -126,9 +126,9 @@ static void load_client ( /*OUT*/ExeInfo* info,
 */
 static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
 {
-   HChar* preload_core    = "vgpreload_core";
-   HChar* ld_preload      = "LD_PRELOAD=";
-   HChar* v_launcher      = VALGRIND_LAUNCHER "=";
+   const HChar* preload_core    = "vgpreload_core";
+   const HChar* ld_preload      = "LD_PRELOAD=";
+   const HChar* v_launcher      = VALGRIND_LAUNCHER "=";
    Int    ld_preload_len  = VG_(strlen)( ld_preload );
    Int    v_launcher_len  = VG_(strlen)( v_launcher );
    Bool   ld_preload_done = False;
@@ -288,10 +288,10 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
 #endif /* AT_SECURE */
 
 /* Add a string onto the string table, and return its address */
-static char *copy_str(char **tab, const char *str)
+static HChar *copy_str(HChar **tab, const HChar *str)
 {
-   char *cp = *tab;
-   char *orig = cp;
+   HChar *cp = *tab;
+   HChar *orig = cp;
 
    while(*str)
       *cp++ = *str++;
@@ -382,16 +382,16 @@ struct auxv *find_auxv(UWord* sp)
 
 static 
 Addr setup_client_stack( void*  init_sp,
-                         char** orig_envp, 
+                         HChar** orig_envp, 
                          const ExeInfo* info,
                          UInt** client_auxv,
                          Addr   clstack_end,
                          SizeT  clstack_max_size )
 {
    SysRes res;
-   char **cpp;
-   char *strtab;               /* string table */
-   char *stringbase;
+   HChar **cpp;
+   HChar *strtab;              /* string table */
+   HChar *stringbase;
    Addr *ptr;
    struct auxv *auxv;
    const struct auxv *orig_auxv;
@@ -468,11 +468,11 @@ Addr setup_client_stack( void*  init_sp,
    /* OK, now we know how big the client stack is */
    stacksize =
       sizeof(Word) +                          /* argc */
-      (have_exename ? sizeof(char **) : 0) +  /* argc[0] == exename */
-      sizeof(char **)*argc +                  /* argv */
-      sizeof(char **) +                              /* terminal NULL */
-      sizeof(char **)*envc +                  /* envp */
-      sizeof(char **) +                              /* terminal NULL */
+      (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */
+      sizeof(HChar **)*argc +                 /* argv */
+      sizeof(HChar **) +                      /* terminal NULL */
+      sizeof(HChar **)*envc +                 /* envp */
+      sizeof(HChar **) +                      /* terminal NULL */
       auxsize +                               /* auxv */
       VG_ROUNDUP(stringsize, sizeof(Word));   /* strings (aligned) */
 
@@ -483,7 +483,7 @@ Addr setup_client_stack( void*  init_sp,
    client_SP = VG_ROUNDDN(client_SP, 16); /* make stack 16 byte aligned */
 
    /* base of the string table (aligned) */
-   stringbase = strtab = (char *)clstack_end 
+   stringbase = strtab = (HChar *)clstack_end 
                          - VG_ROUNDUP(stringsize, sizeof(int));
 
    clstack_start = VG_PGROUNDDN(client_SP);
@@ -1079,9 +1079,9 @@ void VG_(ii_finalise_image)( IIFinaliseImageInfo iifii )
    VG_(memset)(&arch->vex_shadow1, 0xFF, sizeof(VexGuestS390XState));
    VG_(memset)(&arch->vex_shadow2, 0x00, sizeof(VexGuestS390XState));
    /* ... except SP, FPC, and IA */
-   VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_STACK_PTR, 0x00, 8);
-   VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_FPC_REG,   0x00, 4);
-   VG_(memset)((UChar *)&arch->vex_shadow1 + VG_O_INSTR_PTR, 0x00, 8);
+   VG_(memset)(&arch->vex_shadow1 + VG_O_STACK_PTR, 0x00, 8);
+   VG_(memset)(&arch->vex_shadow1 + VG_O_FPC_REG,   0x00, 4);
+   VG_(memset)(&arch->vex_shadow1 + VG_O_INSTR_PTR, 0x00, 8);
 
    /* Put essential stuff into the new state. */
    arch->vex.guest_SP = iifii.initial_client_SP;
index 6065b837d0ff05730d01e24013d93d4212bfd332..91d3f1da2624ef213520f862aa1782994968f4a0 100644 (file)
@@ -61,9 +61,9 @@
    This routine will return True if (*func) returns True and False if
    it reaches the end of the list without that happening.
 */
-static Bool scan_colsep(char *colsep, Bool (*func)(const char *))
+static Bool scan_colsep(HChar *colsep, Bool (*func)(const HChar *))
 {
-   char *cp, *entry;
+   HChar *cp, *entry;
    int end;
 
    if (colsep == NULL ||
@@ -76,7 +76,7 @@ static Bool scan_colsep(char *colsep, Bool (*func)(const char *))
       end = (*cp == '\0');
 
       if (*cp == ':' || *cp == '\0') {
-        char save = *cp;
+        HChar save = *cp;
 
         *cp = '\0';
         if ((*func)(entry)) {
@@ -96,7 +96,7 @@ static Bool scan_colsep(char *colsep, Bool (*func)(const char *))
 static HChar executable_name_in [VKI_PATH_MAX];
 static HChar executable_name_out[VKI_PATH_MAX];
 
-static Bool match_executable(const char *entry) 
+static Bool match_executable(const HChar *entry) 
 {
    HChar buf[VG_(strlen)(entry) + VG_(strlen)(executable_name_in) + 3];
 
@@ -129,7 +129,7 @@ static Bool match_executable(const char *entry)
 }
 
 // Returns NULL if it wasn't found.
-HChar* ML_(find_executable) ( const HChar* exec )
+const HChar* ML_(find_executable) ( const HChar* exec )
 {
    vg_assert(NULL != exec);
    if (VG_(strchr)(exec, '/')) {
index f3169b171f7e7cde7b7901488cc78f522fe46e7c..1afb9a15d5fa746524ea820a407a751318a4f9a1 100644 (file)
@@ -32,6 +32,6 @@
 #ifndef __PRIV_INITIMG_PATHSCAN_H
 #define __PRIV_INITIMG_PATHSCAN_
 
-extern HChar* ML_(find_executable) ( const HChar* exec );
+extern const HChar* ML_(find_executable) ( const HChar* exec );
 
 #endif