mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] test: self: malloc: hide allocation size from compiler
Date: Fri, 10 Nov 2023 14:25:09 +0100	[thread overview]
Message-ID: <20231110132509.GH3359458@pengutronix.de> (raw)
In-Reply-To: <20231109133812.1566381-1-a.fatoum@pengutronix.de>

On Thu, Nov 09, 2023 at 02:38:12PM +0100, Ahmad Fatoum wrote:
> 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(-)

Applied, thanks

Sascha

> 
> 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
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-11-10 13:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-09 13:38 Ahmad Fatoum
2023-11-10 13:25 ` Sascha Hauer [this message]

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=20231110132509.GH3359458@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=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