diff mbox

[stable,03/14] Use VALGRIND callout rather than tricky malloc/memcpy

Message ID 1453348281-16085-4-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Jan. 21, 2016, 3:51 a.m. UTC
commit d04030556db4bb73151172ded3f279882e706dbd upstream

The tricky memcpy trips up various static analysers and looks rather
odd. The more correct thing to do is to ask valgrind to mark it
as undefined. There's a call for that, and we depend on valgrind
to run the test suite anyway, so we're not introducing a new
dependency.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 hdata/test/hdata_to_dt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index 9d23f3385624..9e5abf8f0070 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -25,6 +25,8 @@ 
 
 #include <interrupts.h>
 
+#include <valgrind/memcheck.h>
+
 struct dt_node *opal_node;
 
 /* Our actual map. */
@@ -138,9 +140,7 @@  static void dump_val(unsigned indent, const void *prop, size_t size)
 /* Make sure valgrind knows these are undefined bytes. */
 static void undefined_bytes(void *p, size_t len)
 {
-	void *undef = malloc(len);
-	memcpy(p, undef, len);
-	free(undef);
+	VALGRIND_MAKE_MEM_UNDEFINED(p, len);
 }
 
 static void dump_dt(const struct dt_node *root, unsigned indent)