From: Paul Floyd Date: Tue, 14 Oct 2025 06:27:16 +0000 (+0200) Subject: Fix exe name warnings X-Git-Tag: VALGRIND_3_26_0~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=303ecc60a73237129e2274906cbd883a5ec0edad;p=thirdparty%2Fvalgrind.git 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 --git a/coregrind/m_clientstate.c b/coregrind/m_clientstate.c index 404a60f37..2e4752b8d 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 229867e26..0886b009c 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 489fc7522..3997d30eb 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 aadc2de07..fe83e7360 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 e25a59702..5670838cd 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);