[PATCH] malloc: add indirection for malloc(-like) functions in tests [BZ #32366]

Sam James sam@gentoo.org
Tue Dec 10 00:31:16 GMT 2024


Sam James <sam@gentoo.org> writes:

> Paul Eggert <eggert@cs.ucla.edu> writes:
>
>> On 2024-12-09 15:44, Sam James wrote:
>>
>>> +#define TEST_MALLOC malloc_indirect
>>
>> How about the following instead?
>>
>>   #undef malloc
>>   #define malloc malloc_indirect
>>
>> This is what similar tests do in Gnulib.
>
> I should've mentioned but I tried this and it went awry:
>
> In file included from ../test-skeleton.c:44,
>                  from tst-malloc.c:100:
> ../support/support.h:117:3: error: ‘malloc_indirect’ attribute directive ignored [-Werror=attributes]
>   117 |   __returns_nonnull;
>       |   ^~~~~~~~~~~~~~~~~
> cc1: all warnings being treated as errors
> make: *** [../o-iterator.mk:9: /tmp/glibc-bld/malloc/tst-malloc.o] Error
>
> This is because test-skeleton.c is included at the end of each test
> which includes support.h after, which does:
>
> char *xasprintf (const char *format, ...)
>   __attribute__ ((format (printf, 1, 2), malloc)) __attr_dealloc_free
>   __returns_nonnull;

Actually, malloc -> __malloc__ works here. If that sounds acceptable,
I'll respin with that and post a v2 (assuming no other issues come up).


More information about the Libc-alpha mailing list