From: Florian Krohm Date: Sat, 3 Nov 2012 19:18:10 +0000 (+0000) Subject: Fix Char/HChar mixups and constness in m_initimg. X-Git-Tag: svn/VALGRIND_3_9_0~566 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b906e8df129d5a1409d7193107ea832f2ed9668a;p=thirdparty%2Fvalgrind.git Fix Char/HChar mixups and constness in m_initimg. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13102 --- diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c index 5fa13aa1a8..64671ab2d7 100644 --- a/coregrind/m_initimg/initimg-darwin.c +++ b/coregrind/m_initimg/initimg-darwin.c @@ -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 */ diff --git a/coregrind/m_initimg/initimg-linux.c b/coregrind/m_initimg/initimg-linux.c index f4db0b6768..2bd219887c 100644 --- a/coregrind/m_initimg/initimg-linux.c +++ b/coregrind/m_initimg/initimg-linux.c @@ -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; diff --git a/coregrind/m_initimg/initimg-pathscan.c b/coregrind/m_initimg/initimg-pathscan.c index 6065b837d0..91d3f1da26 100644 --- a/coregrind/m_initimg/initimg-pathscan.c +++ b/coregrind/m_initimg/initimg-pathscan.c @@ -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, '/')) { diff --git a/coregrind/m_initimg/priv_initimg_pathscan.h b/coregrind/m_initimg/priv_initimg_pathscan.h index f3169b171f..1afb9a15d5 100644 --- a/coregrind/m_initimg/priv_initimg_pathscan.h +++ b/coregrind/m_initimg/priv_initimg_pathscan.h @@ -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