From: Julian Seward Date: Thu, 30 Mar 2017 12:14:23 +0000 (+0000) Subject: Bug 358697 - valgrind.h: Some code remains even when defining NVALGRIND. X-Git-Tag: svn/VALGRIND_3_13_0~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d52a222f8bc6b707abd87e9c3fadbe720a735065;p=thirdparty%2Fvalgrind.git 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 --- diff --git a/include/valgrind.h b/include/valgrind.h index dc7dca7b8b..46168aaa9d 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 198d5ff2bc..548f8f791a 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 0000000000..0a9dbe695e --- /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 0000000000..e6e6253b51 --- /dev/null +++ b/none/tests/vgprintf_nvalgrind.vgtest @@ -0,0 +1 @@ +prog: vgprintf_nvalgrind