]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Put valgrind support behind CONFIG_VALGRIND
authorKent Overstreet <kent.overstreet@gmail.com>
Wed, 4 Dec 2019 22:49:34 +0000 (17:49 -0500)
committerKent Overstreet <kent.overstreet@gmail.com>
Wed, 4 Dec 2019 22:49:34 +0000 (17:49 -0500)
Makefile
include/linux/bug.h
linux/blkdev.c

index adea7611d8092a0f81b1431bf61ae4593a72b7c7..5bd696a2e842b28d336f2aa23ff3b5c5e5f67e70 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ endif
 ifdef D
        CFLAGS+=-Werror
        CFLAGS+=-DCONFIG_BCACHEFS_DEBUG=y
+       CFLAGS+=-DCONFIG_VALGRIND=y
 endif
 
 PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd"
index eb53f39c15958c7fbdc94159417732d450814c7f..d47f5a494e26a423f1c362e2692183bd477e2a0b 100644 (file)
@@ -3,8 +3,13 @@
 
 #include <assert.h>
 #include <linux/compiler.h>
+
+#ifdef CONFIG_VALGRIND
 #include <valgrind/memcheck.h>
 
+#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
+#endif
+
 #define BUILD_BUG_ON_NOT_POWER_OF_2(n)                 \
        BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0))
 #define BUILD_BUG_ON_ZERO(e)   (sizeof(struct { int:-!!(e); }))
@@ -53,6 +58,4 @@
        __ret_warn_on;                                                  \
 })
 
-#define DEBUG_MEMORY_FREED(p, len) VALGRIND_MAKE_MEM_UNDEFINED(p, len)
-
 #endif /* __TOOLS_LINUX_BUG_H */
index 219f888e8a22ea1094903bd0284845db293a88ca..709e770345f925e31101a82ea3bd5366525bb848 100644 (file)
@@ -10,7 +10,9 @@
 
 #include <libaio.h>
 
+#ifdef CONFIG_VALGRIND
 #include <valgrind/memcheck.h>
+#endif
 
 #include <linux/bio.h>
 #include <linux/blkdev.h>
@@ -57,9 +59,11 @@ void generic_make_request(struct bio *bio)
                        .iov_len = len,
                };
 
+#ifdef CONFIG_VALGRIND
                /* To be pedantic it should only be on IO completion. */
                if (bio_op(bio) == REQ_OP_READ)
                        VALGRIND_MAKE_MEM_DEFINED(start, len);
+#endif
        }
 
        struct iocb iocb = {