|
From: Paul F. <pa...@so...> - 2026-03-13 22:27:52
|
https://sourceware.org/cgit/valgrind/commit/?id=e43f320b504a99edc45f1b5d0dce6fabde023b93 commit e43f320b504a99edc45f1b5d0dce6fabde023b93 Author: Paul Floyd <pj...@wa...> Date: Fri Mar 13 23:26:07 2026 +0100 Fix GCC -Waddress warnings These are warnings where there is a NULL check for something that can never be NULL, mostly char arrays. Diff: --- coregrind/m_main.c | 6 +++--- coregrind/m_syswrap/syswrap-generic.c | 8 ++++---- coregrind/m_ume/main.c | 2 +- helgrind/libhb_core.c | 1 - include/pub_tool_libcbase.h | 4 ++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/coregrind/m_main.c b/coregrind/m_main.c index cb4f97f2ad..5cf629f779 100644 --- a/coregrind/m_main.c +++ b/coregrind/m_main.c @@ -458,9 +458,9 @@ static void process_option (Clo_Mode mode, // in case someone has combined a prefix with a core-specific option, // eg. "--memcheck:verbose". if (*colon == ':') { - if (VG_STREQN(2, arg, "--") && - VG_STREQN(toolname_len, arg+2, VG_(clo_toolname)) && - VG_STREQN(1, arg+2+toolname_len, ":")) { + if (VG_STREQN(2, arg, "--") && + VG_(strncmp)(arg+2, VG_(clo_toolname), toolname_len)==0 && + VG_(strncmp)(arg+2+toolname_len, ":", 1)==0) { // Prefix matches, convert "--toolname:foo" to "--foo". // Two things to note: // - We cannot modify the option in-place. If we did, and then diff --git a/coregrind/m_syswrap/syswrap-generic.c b/coregrind/m_syswrap/syswrap-generic.c index 1cd592196b..3d31c53e72 100644 --- a/coregrind/m_syswrap/syswrap-generic.c +++ b/coregrind/m_syswrap/syswrap-generic.c @@ -4789,7 +4789,7 @@ static Bool handle_auxv_open(SyscallStatus *status, const HChar *filename, /* Opening /proc/<pid>/auxv or /proc/self/auxv? */ VG_(sprintf)(name, "/proc/%d/auxv", VG_(getpid)()); - if (!VG_STREQ(filename, name) && !VG_STREQ(filename, "/proc/self/auxv")) + if ((VG_(strcmp)(filename, name)!=0) && !VG_STREQ(filename, "/proc/self/auxv")) return False; /* Allow to open the file only for reading. */ @@ -4819,7 +4819,7 @@ static Bool handle_self_exe_open(SyscallStatus *status, const HChar *filename, /* Opening /proc/<pid>/exe or /proc/self/exe? */ VG_(sprintf)(name, "/proc/%d/exe", VG_(getpid)()); - if (!VG_STREQ(filename, name) && !VG_STREQ(filename, "/proc/self/exe")) + if ((VG_(strcmp)(filename, name)!=0) && !VG_STREQ(filename, "/proc/self/exe")) return False; /* Allow to open the file only for reading. */ @@ -4910,7 +4910,7 @@ PRE(sys_open) VG_(sprintf)(name, "/proc/%d/cmdline", VG_(getpid)()); if (ML_(safe_to_deref)( arg1s, 1 ) - && (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, "/proc/self/cmdline"))) { + && (VG_(strcmp)(arg1s, name)==0 || VG_STREQ(arg1s, "/proc/self/cmdline"))) { sres = VG_(dup)( VG_(cl_cmdline_fd) ); SET_STATUS_from_SysRes( sres ); if (!sr_isError(sres)) { @@ -5094,7 +5094,7 @@ PRE(sys_readlink) HChar* arg1s = (HChar*) (Addr)ARG1; VG_(sprintf)(name, PID_EXEPATH, VG_(getpid)()); if (ML_(safe_to_deref)(arg1s, 1) - && (VG_STREQ(arg1s, name) || VG_STREQ(arg1s, SELF_EXEPATH))) { + && (VG_(strcmp)(arg1s, name)==0 || VG_STREQ(arg1s, SELF_EXEPATH))) { HChar* out_name = (HChar*)ARG2; SizeT res = VG_(strlen)(VG_(resolved_exename)); res = VG_MIN(res, ARG3); diff --git a/coregrind/m_ume/main.c b/coregrind/m_ume/main.c index bca641eb25..21e64592a0 100644 --- a/coregrind/m_ume/main.c +++ b/coregrind/m_ume/main.c @@ -161,7 +161,7 @@ static Bool is_hash_bang_file(const HChar* f) HChar buf[3] = {0,0,0}; Int fd = sr_Res(res); Int n = VG_(read)(fd, buf, 2); - if (n == 2 && VG_STREQ("#!", buf)) + if (n == 2 && (VG_(strcmp)(buf, "#!")==0)) return True; } return False; diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c index 302028acec..f5c50a21e1 100644 --- a/helgrind/libhb_core.c +++ b/helgrind/libhb_core.c @@ -3158,7 +3158,6 @@ static void vts_tab__do_GC ( Bool show_stats ) tl_assert(old_te->u.remap == VtsID_INVALID); tl_assert(old_vts != NULL); tl_assert(old_vts->id == i); - tl_assert(old_vts->ts != NULL); /* It is in use. Make a pruned version. */ nBeforePruning++; diff --git a/include/pub_tool_libcbase.h b/include/pub_tool_libcbase.h index 7fb7bf04de..854d7e3116 100644 --- a/include/pub_tool_libcbase.h +++ b/include/pub_tool_libcbase.h @@ -72,9 +72,9 @@ extern double VG_(strtod) ( const HChar* str, HChar** endptr ); ------------------------------------------------------------------ */ /* Use this for normal null-termination-style string comparison. */ -#define VG_STREQ(s1,s2) ( (s1 != NULL && s2 != NULL \ +#define VG_STREQ(s1,s2) ( ((s1) != NULL && (s2) != NULL \ && VG_(strcmp)((s1),(s2))==0) ? True : False ) -#define VG_STREQN(n,s1,s2) ( (s1 != NULL && s2 != NULL \ +#define VG_STREQN(n,s1,s2) ( ((s1) != NULL && (s2) != NULL \ && VG_(strncmp)((s1),(s2),(n))==0) ? True : False ) extern SizeT VG_(strlen) ( const HChar* str ); |