From: Mark Wielaard Date: Sun, 10 Oct 2021 13:56:50 +0000 (+0200) Subject: Remove some warnings from tests X-Git-Tag: VALGRIND_3_18_0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4015813336b620f1642d630963327bf484150648;p=thirdparty%2Fvalgrind.git Remove some warnings from tests 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. --- diff --git a/dhat/tests/Makefile.am b/dhat/tests/Makefile.am index ce01a742f7..3b0cd3e62a 100644 --- a/dhat/tests/Makefile.am +++ b/dhat/tests/Makefile.am @@ -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 diff --git a/massif/tests/Makefile.am b/massif/tests/Makefile.am index 5b5ee599b3..0ecf09676a 100644 --- a/massif/tests/Makefile.am +++ b/massif/tests/Makefile.am @@ -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 diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 3ce33af181..d7759296fc 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -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@ diff --git a/none/tests/mq.c b/none/tests/mq.c index 6c1af148ae..72c150d9a5 100644 --- a/none/tests/mq.c +++ b/none/tests/mq.c @@ -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);