|
From: Paul F. <pa...@so...> - 2025-10-14 06:35:30
|
https://sourceware.org/cgit/valgrind/commit/?id=303ecc60a73237129e2274906cbd883a5ec0edad commit 303ecc60a73237129e2274906cbd883a5ec0edad Author: Paul Floyd <pj...@wa...> Date: Tue Oct 14 08:27:16 2025 +0200 Fix exe name warnings Most of the exe name functions can take a const char* for the name. Indeed, on Linux this is a requirement since we also lookup debuginfod-find using a const char string literal. The exception to this rule is for scripts. In this case the script shebang can refer to another script with another shebang. And so on until eventually an ELF or macho file is encountered. In that case VG_(args_the_exename) will get freed if necessary and reassigned to a new string. So VG_(load_script) needs to be able to take a non-const char* name, unlike VG_(load_ELF) and VG_(load_macho). VG_(args_the_exename) is now non-const (which fixes a warning when freeing it), VG_(load_script) takes a non-const name and there is an ugly cast for the function pointer. Diff: --- coregrind/m_clientstate.c | 2 +- coregrind/m_ume/main.c | 3 ++- coregrind/m_ume/priv_ume.h | 2 +- coregrind/m_ume/script.c | 2 +- include/pub_tool_clientstate.h | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/coregrind/m_clientstate.c b/coregrind/m_clientstate.c index 404a60f372..2e4752b8d6 100644 --- a/coregrind/m_clientstate.c +++ b/coregrind/m_clientstate.c @@ -91,7 +91,7 @@ Int VG_(args_for_valgrind_noexecpass) = 0; /* The name of the client executable, as specified on the command line. */ -const HChar* VG_(args_the_exename) = NULL; +HChar* VG_(args_the_exename) = NULL; /* The real name of the executable, with resolved * relative paths and symlinks */ diff --git a/coregrind/m_ume/main.c b/coregrind/m_ume/main.c index 229867e268..0886b009c1 100644 --- a/coregrind/m_ume/main.c +++ b/coregrind/m_ume/main.c @@ -42,6 +42,7 @@ #include "priv_ume.h" +typedef Int (*load_function)( Int fd, const HChar *name, ExeInfo *info ); typedef struct { Bool (*match_fn)(const void *hdr, SizeT len); @@ -56,7 +57,7 @@ static ExeHandler exe_handlers[] = { # else # error "unknown OS" # endif - { VG_(match_script), VG_(load_script) }, + { VG_(match_script), (load_function)VG_(load_script) }, }; #define EXE_HANDLER_COUNT (sizeof(exe_handlers)/sizeof(exe_handlers[0])) diff --git a/coregrind/m_ume/priv_ume.h b/coregrind/m_ume/priv_ume.h index 489fc75229..3997d30eb1 100644 --- a/coregrind/m_ume/priv_ume.h +++ b/coregrind/m_ume/priv_ume.h @@ -45,7 +45,7 @@ extern Int VG_(load_macho) ( Int fd, const HChar *name, ExeInfo *info ); #endif extern Bool VG_(match_script) ( const void *hdr, SizeT len ); -extern Int VG_(load_script) ( Int fd, const HChar *name, ExeInfo *info ); +extern Int VG_(load_script) ( Int fd, HChar *name, ExeInfo *info ); #endif // __PRIV_UME_H diff --git a/coregrind/m_ume/script.c b/coregrind/m_ume/script.c index aadc2de075..fe83e73608 100644 --- a/coregrind/m_ume/script.c +++ b/coregrind/m_ume/script.c @@ -67,7 +67,7 @@ Bool VG_(match_script)(const void *hdr, SizeT len) /* returns: 0 = success, non-0 is failure */ -Int VG_(load_script)(Int fd, const HChar* name, ExeInfo* info) +Int VG_(load_script)(Int fd, HChar* name, ExeInfo* info) { HChar hdr[4096]; Int len = sizeof hdr; diff --git a/include/pub_tool_clientstate.h b/include/pub_tool_clientstate.h index e25a59702a..5670838cd1 100644 --- a/include/pub_tool_clientstate.h +++ b/include/pub_tool_clientstate.h @@ -61,7 +61,7 @@ extern Int VG_(args_for_valgrind_noexecpass); /* The name of the client executable, as specified on the command line. */ -extern const HChar* VG_(args_the_exename); +extern HChar* VG_(args_the_exename); extern const HChar* VG_(resolved_exename); |