[PATCH] test: self: malloc: hide allocation size from compiler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Once we start annotating malloc with __attribute((alloc_size)), GCC will
detect that we intentionally buffers that are too big.

Avoid the warning by hiding the size using the RELOC_HIDE macro.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 test/self/malloc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/self/malloc.c b/test/self/malloc.c
index 47c225ac6a10..0feec810185f 100644
--- a/test/self/malloc.c
+++ b/test/self/malloc.c
@@ -85,11 +85,11 @@ static void test_malloc(void)
 	free(p);
 
 	if (mem_malloc_size) {
-		tmp = expect_alloc_fail(malloc(SIZE_MAX));
+		tmp = expect_alloc_fail(malloc(RELOC_HIDE(SIZE_MAX, 0)));
 		free(tmp);
 
 		if (0xf0000000 > mem_malloc_size) {
-			tmp = expect_alloc_fail(malloc(0xf0000000));
+			tmp = expect_alloc_fail(malloc(RELOC_HIDE(0xf0000000, 0)));
 			free(tmp);
 		}
 	} else {
@@ -111,11 +111,11 @@ static void test_malloc(void)
 		free(tmp);
 
 		if (0xf0000000 > mem_malloc_size) {
-			tmp = expect_alloc_fail(realloc(p, 0xf0000000));
+			tmp = expect_alloc_fail(realloc(p, RELOC_HIDE(0xf0000000, 0)));
 			free(tmp);
 		}
 
-		tmp = expect_alloc_fail(realloc(p, SIZE_MAX));
+		tmp = expect_alloc_fail(realloc(p, RELOC_HIDE(SIZE_MAX, 0)));
 		free(tmp);
 
 	} else {
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux