From 50b7492e67b314192012f7a776c635999317bfb9 Mon Sep 17 00:00:00 2001 From: Jeffrey Ryan Date: Fri, 16 Sep 2022 10:45:32 -0500 Subject: [PATCH] unit_tests: suppress memwipe unit warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes warning: ``` warning: ‘*(uint32_t*)quux’ may be used uninitialized [-Wmaybe-uninitialized] 49 | MDEBUG(std::hex << std::setw(8) << std::setfill('0') << *(uint32_t*)quux); warning: ‘quux’ may be used uninitialized [-Wmaybe-uninitialized] 50 | if (wipe) { ASSERT_TRUE(memcmp(quux, "bar", 3)); } ``` --- tests/unit_tests/memwipe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/unit_tests/memwipe.cpp b/tests/unit_tests/memwipe.cpp index 97f003471..8eab69548 100644 --- a/tests/unit_tests/memwipe.cpp +++ b/tests/unit_tests/memwipe.cpp @@ -31,6 +31,7 @@ #include #include "misc_log_ex.h" #include "memwipe.h" +#include "warnings.h" // Probably won't catch the optimized out case, but at least we test // it works in the normal case @@ -44,12 +45,15 @@ static void test(bool wipe) ASSERT_EQ(foo, bar); free(foo); char *quux = (char*)malloc(4); // same size, just after free, so we're likely to get the same, depending on the allocator +PUSH_WARNINGS +DISABLE_GCC_WARNING(maybe-uninitialized) if ((intptr_t)quux == foop) { MDEBUG(std::hex << std::setw(8) << std::setfill('0') << *(uint32_t*)quux); if (wipe) { ASSERT_TRUE(memcmp(quux, "bar", 3)); } } else MWARNING("We did not get the same location, cannot check"); +POP_WARNINGS free(quux); }