kernel32: Disable diagnostics when testing corner cases in test_heap().

Gerald Pfeifer gerald at pfeifer.com
Sat Feb 11 15:41:24 CST 2017


GCC 7 is going to add quite a number of additional warnings, and many
of those will be enabled by default with -Wall -Wextra.

With that dlls/kernel32/tests/heap.c triggers three warnings, all of
which are correct positives, but in fact do want to test those corner
cases:

 heap.c:114:13: warning: argument 4 value '4294967288' exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
 heap.c:116:13: warning: argument 4 value '4294967295' exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
 heap.c:119:9: warning: argument 3 value '4294967295' exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]

The best way to silence such warnings without disabling them too
aggressively is via #pragmas around the affected code.  I verified
that the patch below silences those three warnings.

Gerald


Signed-off-by: Gerald Pfeifer <gerald at pfeifer.com>
---
 dlls/kernel32/tests/heap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c
index 2f7edc823c..2bb66c6327 100644
--- a/dlls/kernel32/tests/heap.c
+++ b/dlls/kernel32/tests/heap.c
@@ -111,6 +111,9 @@ static void test_heap(void)
     /* test some border cases of HeapAlloc and HeapReAlloc */
     mem = HeapAlloc(GetProcessHeap(), 0, 0);
     ok(mem != NULL, "memory not allocated for size 0\n");
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
     msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0 - 7);
     ok(msecond == NULL, "HeapReAlloc(~0 - 7) should have failed\n");
     msecond = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, ~(SIZE_T)0);
@@ -118,6 +121,7 @@ static void test_heap(void)
     HeapFree(GetProcessHeap(), 0, mem);
     mem = HeapAlloc(GetProcessHeap(), 0, ~(SIZE_T)0);
     ok(mem == NULL, "memory allocated for size ~0\n");
+#pragma GCC diagnostic pop
 
     /* large blocks must be 16-byte aligned */
     mem = HeapAlloc(GetProcessHeap(), 0, 512 * 1024);
-- 
2.11.0



More information about the wine-patches mailing list