Minor trimming of false positives from valgrind.
authorCarl Hetherington <cth@carlh.net>
Mon, 2 Jun 2014 14:35:53 +0000 (15:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 2 Jun 2014 14:35:53 +0000 (15:35 +0100)
asdcplib/src/KM_prng.cpp
wscript

index 463ae15752cf30d05987570737e33e6540a0d19f..7a0100c1d8ae4d20988048892ecc605501c0afbf 100755 (executable)
@@ -39,7 +39,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <openssl/aes.h>
 #include <openssl/sha.h>
 #include <openssl/bn.h>
-
+#ifdef LIBDCP_VALGRIND
+#include <valgrind/memcheck.h>
+#endif
+  
 using namespace Kumu;
 
 
@@ -118,6 +121,10 @@ public:
     SHA1_Update(&SHA, key_fodder, RNG_KEY_SIZE);
     SHA1_Final(sha_buf, &SHA);
 
+#ifdef LIBDCP_VALGRIND
+    VALGRIND_MAKE_MEM_DEFINED (sha_buf, 20);
+#endif
+
     AutoMutex Lock(m_Lock);
     AES_set_encrypt_key(sha_buf, RNG_KEY_SIZE_BITS, &m_Context);
     *(ui32_t*)(m_ctr_buf + 12) = 1;
diff --git a/wscript b/wscript
index c66d3fbd9ad2b99ffb89d386d368ee42e76a9dc5..5a228368bfcb972ecbf31d091c896137ff1e90fe 100644 (file)
--- a/wscript
+++ b/wscript
@@ -10,6 +10,7 @@ def options(opt):
     opt.add_option('--osx', action='store_true', default=False, help='set up to build on OS X')
     opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
     opt.add_option('--static', action='store_true', default=False, help='build libdcp and in-tree dependencies statically, and link statically to openjpeg and cxml')
+    opt.add_option('--valgrind', action='store_true', default=False, help='build with instructions to Valgrind to reduce false positives')
 
 def configure(conf):
     conf.load('compiler_cxx')
@@ -26,6 +27,9 @@ def configure(conf):
     else:
         conf.env.append_value('CXXFLAGS', '-DLIBDCP_POSIX')
 
+    if conf.options.valgrind:
+        conf.env.append_value('CXXFLAGS', '-DLIBDCP_VALGRIND')
+
     if not conf.options.osx:
         conf.env.append_value('CXXFLAGS', ['-Wno-unused-result', '-Wno-unused-parameter'])