From d52a222f8bc6b707abd87e9c3fadbe720a735065 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Thu, 30 Mar 2017 12:14:23 +0000 Subject: [PATCH] Bug 358697 - valgrind.h: Some code remains even when defining NVALGRIND. Patch from Matthias Schwarzott (zzam@gentoo.org). The patch removes a volatile memory read which was only there to stop compilers warning about |format| being unused. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16290 --- include/valgrind.h | 4 ++-- none/tests/Makefile.am | 5 +++++ none/tests/vgprintf_nvalgrind.stderr.exp | 4 ++++ none/tests/vgprintf_nvalgrind.vgtest | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 none/tests/vgprintf_nvalgrind.stderr.exp create mode 100644 none/tests/vgprintf_nvalgrind.vgtest diff --git a/include/valgrind.h b/include/valgrind.h index dc7dca7b8..46168aaa9 100644 --- a/include/valgrind.h +++ b/include/valgrind.h @@ -6769,7 +6769,7 @@ __inline VALGRIND_PRINTF(const char *format, ...) { #if defined(NVALGRIND) - if (format) *(volatile const char *)format; /* avoid compiler warning */ + (void)format; return 0; #else /* NVALGRIND */ #if defined(_MSC_VER) || defined(__MINGW64__) @@ -6808,7 +6808,7 @@ __inline VALGRIND_PRINTF_BACKTRACE(const char *format, ...) { #if defined(NVALGRIND) - if (format) *(volatile const char *)format; /* avoid compiler warning */ + (void)format; return 0; #else /* NVALGRIND */ #if defined(_MSC_VER) || defined(__MINGW64__) diff --git a/none/tests/Makefile.am b/none/tests/Makefile.am index 198d5ff2b..548f8f791 100644 --- a/none/tests/Makefile.am +++ b/none/tests/Makefile.am @@ -203,6 +203,7 @@ EXTRA_DIST = \ tls.vgtest tls.stderr.exp tls.stdout.exp \ unit_debuglog.stderr.exp unit_debuglog.vgtest \ vgprintf.stderr.exp vgprintf.vgtest \ + vgprintf_nvalgrind.stderr.exp vgprintf_nvalgrind.vgtest \ process_vm_readv_writev.stderr.exp process_vm_readv_writev.vgtest check_PROGRAMS = \ @@ -248,6 +249,7 @@ check_PROGRAMS = \ unit_debuglog \ valgrind_cpp_test \ vgprintf \ + vgprintf_nvalgrind \ coolo_sigaction \ gxx304 \ process_vm_readv_writev @@ -362,6 +364,9 @@ else tls2_so_LDFLAGS = -shared endif +vgprintf_nvalgrind_SOURCES = vgprintf.c +vgprintf_nvalgrind_CFLAGS = -DNVALGRIND + valgrind_cpp_test_SOURCES = valgrind_cpp_test.cpp valgrind_cpp_test_LDADD = -lstdc++ diff --git a/none/tests/vgprintf_nvalgrind.stderr.exp b/none/tests/vgprintf_nvalgrind.stderr.exp new file mode 100644 index 000000000..0a9dbe695 --- /dev/null +++ b/none/tests/vgprintf_nvalgrind.stderr.exp @@ -0,0 +1,4 @@ + +0 +0 + diff --git a/none/tests/vgprintf_nvalgrind.vgtest b/none/tests/vgprintf_nvalgrind.vgtest new file mode 100644 index 000000000..e6e6253b5 --- /dev/null +++ b/none/tests/vgprintf_nvalgrind.vgtest @@ -0,0 +1 @@ +prog: vgprintf_nvalgrind