]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix exe name warnings
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 14 Oct 2025 06:27:16 +0000 (08:27 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 14 Oct 2025 06:27:16 +0000 (08:27 +0200)
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.

coregrind/m_clientstate.c
coregrind/m_ume/main.c
coregrind/m_ume/priv_ume.h
coregrind/m_ume/script.c
include/pub_tool_clientstate.h

index 404a60f3720e5fefe14421f62a431786ade7090c..2e4752b8d6b9cf15cad0c1a6e331660e38d6d80e 100644 (file)
@@ -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 */
index 229867e2684fd4848c474a90975c556337471159..0886b009c1ba5962d096bbcb9ad9d1bf55bcb1a9 100644 (file)
@@ -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]))
 
index 489fc75229c20fa466061f20d8caaf8623eaceea..3997d30eb1202d54d49dd468276c6b9d97a85936 100644 (file)
@@ -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
index aadc2de0755305b81fe2f310dfeb8667f9cbab86..fe83e73608221e8e843202c2ad2c4156f7a559ef 100644 (file)
@@ -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;
index e25a59702ae186368adffc9c1c12d721facca4aa..5670838cd1378ae65483847da8ec47a2706d62f1 100644 (file)
@@ -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);