From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] test: self: malloc: hide allocation size from compiler
Date: Thu, 9 Nov 2023 14:38:12 +0100 [thread overview]
Message-ID: <20231109133812.1566381-1-a.fatoum@pengutronix.de> (raw)
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@pengutronix.de>
---
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
next reply other threads:[~2023-11-09 13:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 13:38 Ahmad Fatoum [this message]
2023-11-10 13:25 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231109133812.1566381-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox