Fix Char/HChar mixups and constness in m_initimg.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13102 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/m_initimg/initimg-darwin.c b/coregrind/m_initimg/initimg-darwin.c
index 5fa13aa..64671ab 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 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 @@
/*====================================================================*/
/* 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
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 @@
/* 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 @@
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 f4db0b6..2bd2198 100644
--- a/coregrind/m_initimg/initimg-linux.c
+++ b/coregrind/m_initimg/initimg-linux.c
@@ -71,7 +71,7 @@
/*OUT*/Addr* client_ip,
/*OUT*/Addr* client_toc)
{
- HChar* exe_name;
+ const HChar* exe_name;
Int ret;
SysRes res;
@@ -126,9 +126,9 @@
*/
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 @@
#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 @@
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 @@
/* 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 @@
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 @@
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 6065b83..91d3f1d 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 @@
end = (*cp == '\0');
if (*cp == ':' || *cp == '\0') {
- char save = *cp;
+ HChar save = *cp;
*cp = '\0';
if ((*func)(entry)) {
@@ -96,7 +96,7 @@
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 @@
}
// 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 f3169b1..1afb9a1 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