]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix GCC -Waddress warnings
authorPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 13 Mar 2026 22:26:07 +0000 (23:26 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Fri, 13 Mar 2026 22:26:07 +0000 (23:26 +0100)
These are warnings where there is a NULL check for something that
can never be NULL, mostly char arrays.

coregrind/m_main.c
coregrind/m_syswrap/syswrap-generic.c
coregrind/m_ume/main.c
helgrind/libhb_core.c
include/pub_tool_libcbase.h

index cb4f97f2adafa68ee7701b921a7434ddcb693035..5cf629f7794db10028484c6a5fa54334ee970d92 100644 (file)
@@ -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
index 1cd592196bf46f2a715ac17c97394e7a083637d5..3d31c53e72edfc21ab720d7e77805f419120ba69 100644 (file)
@@ -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);
index bca641eb25dbe5a1c9078bbd323a4f187aeb617e..21e64592a023dff97e289325cc8b19de27e56bc4 100644 (file)
@@ -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;
index 302028aceca05d7f22ea9806cd72968f8bb06c98..f5c50a21e138e33c2df6eff173e84a12097dc6dd 100644 (file)
@@ -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++;
index 7fb7bf04de306cd360ed84d855d0658a9fef49e1..854d7e311627eca814901e003fb0591d356b697f 100644 (file)
@@ -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 );