From 45c5180872fd2b429104da9fae9f3ca68f2b9189 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9ctor=20Or=C3=B3n=20Mart=C3=ADnez?= <zumbi@debian.org>
Date: Tue, 21 Aug 2018 01:39:25 +0200
Subject: [PATCH 1/4] Revert "tests: Better handling of valgrind errors saving
 blobs"

This reverts commit 5b67d2b955a3ef6bc4ce6fec3b06c660539aa8ce.
---
 tests/mangle-layout.supp |  7 +++++++
 tests/open_pack.supp     |  7 +++++++
 tests/sw_tree1.supp      | 18 ++++++++++++++++++
 tests/testutils.c        | 15 ++-------------
 4 files changed, 34 insertions(+), 13 deletions(-)
 create mode 100644 tests/mangle-layout.supp
 create mode 100644 tests/open_pack.supp
 create mode 100644 tests/sw_tree1.supp

diff --git a/tests/mangle-layout.supp b/tests/mangle-layout.supp
new file mode 100644
index 0000000..2890420
--- /dev/null
+++ b/tests/mangle-layout.supp
@@ -0,0 +1,7 @@
+{
+   uninitialized alignment gaps can be dumped to output
+   Memcheck:Param
+   write(buf)
+   obj:/lib/ld-*.so
+   fun:main
+}
diff --git a/tests/open_pack.supp b/tests/open_pack.supp
new file mode 100644
index 0000000..c954fe7
--- /dev/null
+++ b/tests/open_pack.supp
@@ -0,0 +1,7 @@
+{
+   opened blob dumps uninitialized data
+   Memcheck:Param
+   write(buf)
+   obj:/lib/ld-*.so
+   fun:main
+}
diff --git a/tests/sw_tree1.supp b/tests/sw_tree1.supp
new file mode 100644
index 0000000..fcb1950
--- /dev/null
+++ b/tests/sw_tree1.supp
@@ -0,0 +1,18 @@
+{
+   allocation methods causes uninitialized data in alignment gap
+   Memcheck:Param
+   write(buf)
+   fun:__write_nocancel
+   fun:utilfdt_write_err
+   fun:save_blob
+   fun:main
+}
+{
+   allocation methods causes uninitialized data in alignment gap
+   Memcheck:Param
+   write(buf)
+   fun:write
+   fun:utilfdt_write_err
+   fun:save_blob
+   fun:main
+}
diff --git a/tests/testutils.c b/tests/testutils.c
index 75e3e20..6d5883f 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -30,8 +30,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#include <valgrind/memcheck.h>
-
 #include <libfdt.h>
 
 #include "tests.h"
@@ -236,20 +234,11 @@ void *load_blob_arg(int argc, char *argv[])
 
 void save_blob(const char *filename, void *fdt)
 {
-	size_t size = fdt_totalsize(fdt);
-	void *tmp;
-	int ret;
-
-	/* Make a temp copy of the blob so that valgrind won't check
-	 * about uninitialized bits in the pieces between blocks */
-	tmp = xmalloc(size);
-	fdt_move(fdt, tmp, size);
-	VALGRIND_MAKE_MEM_DEFINED(tmp, size);
-	ret = utilfdt_write_err(filename, tmp);
+	int ret = utilfdt_write_err(filename, fdt);
+
 	if (ret)
 		CONFIG("Couldn't write blob to \"%s\": %s", filename,
 		       strerror(ret));
-	free(tmp);
 }
 
 void *open_blob_rw(void *blob)
-- 
2.18.0

