]> sourceware.org Git - valgrind.git/commitdiff
Remove some warnings from tests
authorMark Wielaard <mark@klomp.org>
Sun, 10 Oct 2021 13:56:50 +0000 (15:56 +0200)
committerMark Wielaard <mark@klomp.org>
Sun, 10 Oct 2021 13:56:50 +0000 (15:56 +0200)
Various tests do things which we want to detect at runtime, like
ignoring the result of malloc or doing a deliberate impossibly large
allocation or operations that would result in overflowing or
truncated strings, that generate a warning from gcc.

In once case, mq_setattr called with new and old attrs overlapping,
this was explicitly fixed, in others -Wno-foobar was added to silence
the warning. This is safe even for older gcc, since a compiler will
ignore any -Wno-foobar they don't know about - since they do know they
won't warn for foobar.

dhat/tests/Makefile.am
massif/tests/Makefile.am
memcheck/tests/Makefile.am
none/tests/mq.c

index ce01a742f72fcf8accce777f3c93ad3960a16ee2..3b0cd3e62afd5b722bf1a298bd76c5e7ca95f585 100644 (file)
@@ -26,3 +26,5 @@ check_PROGRAMS = \
 AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
 
+# We don't care about unused malloc results
+big_CFLAGS  = $(AM_CFLAGS) -Wno-unused-result
index 5b5ee599b3327d82218dd5fbb8cfde3113a98d3c..0ecf09676a0e40aff67d43accd601d1f6ee6eed6 100644 (file)
@@ -89,3 +89,14 @@ AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
 new_cpp_SOURCES                = new-cpp.cpp
 overloaded_new_SOURCES = overloaded-new.cpp
 
+# Suppress warnings for issues we are testing for
+alloc_fns_CFLAGS       = $(AM_CFLAGS) -Wno-unused-result
+big_alloc_CFLAGS       = $(AM_CFLAGS) -Wno-unused-result
+culling1_CFLAGS                = $(AM_CFLAGS) -Wno-unused-result
+culling2_CFLAGS                = $(AM_CFLAGS) -Wno-unused-result
+deep_CFLAGS            = $(AM_CFLAGS) -Wno-unused-result
+ignoring_CFLAGS                = $(AM_CFLAGS) -Wno-unused-result
+insig_CFLAGS           = $(AM_CFLAGS) -Wno-unused-result
+long_names_CFLAGS      = $(AM_CFLAGS) -Wno-unused-result
+one_CFLAGS             = $(AM_CFLAGS) -Wno-unused-result
+thresholds_CFLAGS      = $(AM_CFLAGS) -Wno-unused-result
index 3ce33af1819fdeea4628c9ef94cc5a23b68335a0..d7759296fc5217a933394453ca3aa64e14b32026 100644 (file)
@@ -505,6 +505,12 @@ leak_cpp_interior_SOURCES  = leak_cpp_interior.cpp
 
 demangle_SOURCES = demangle.cpp
 
+# Suppress various gcc warnings which are correct, but for things
+# we are actually testing for at runtime.
+accounting_CFLAGS      = $(AM_CFLAGS) -Wno-alloc-size-larger-than
+bug155125_CFLAGS       = $(AM_CFLAGS) -Wno-unused-result -Wno-alloc-size-larger-than
+malloc3_CFLAGS         = $(AM_CFLAGS) -Wno-alloc-size-larger-than
+
 big_debuginfo_symbol_SOURCES = big_debuginfo_symbol.cpp
 big_debuginfo_symbol_CXXFLAGS = $(AM_CXXFLAGS) -std=c++0x
 
@@ -590,7 +596,8 @@ sized_delete_SOURCES   = sized_delete.cpp
 sized_delete_CXXFLAGS  = $(AM_CXXFLAGS) @FLAG_FSIZED_DEALLOCATION@
 endif
 
-str_tester_CFLAGS      = $(AM_CFLAGS) -Wno-shadow \
+str_tester_CFLAGS      = $(AM_CFLAGS) -Wno-shadow -Wno-stringop-overflow \
+                         -Wno-stringop-truncation \
                          @FLAG_W_NO_MEMSET_TRANSPOSED_ARGS@
 
 supp_CFLAGS             = $(AM_CFLAGS) @FLAG_W_NO_UNINITIALIZED@
index 6c1af148ae8b1494e2fa27c5e88e4c4adaee40b1..72c150d9a5a4511e3f3fa897790acccecefc7fd4 100644 (file)
@@ -15,7 +15,7 @@
 
 int main(int argc, char **argv)
 {
-  struct mq_attr mqa;
+  struct mq_attr mqa, mqa2;
   mqd_t mqdw;
   mqd_t mqdr;
   char buffer[MSGSIZEMAX];
@@ -89,7 +89,8 @@ int main(int argc, char **argv)
       exit(1);
     }
 
-  if (mq_setattr(mqdw, &mqa, &mqa) < 0)
+  mqa2 = mqa;
+  if (mq_setattr(mqdw, &mqa, &mqa2) < 0)
     {
       perror("mq_setattr");
       mq_close(mqdr);
This page took 0.039025 seconds and 5 git commands to generate.