Re: [PATCH v3 2/3] win32: allow building with pedantic mode enabled
- From
René Scharfe <l.s.r@web.de>
- Date
- Sep 3, 2021, 18:47 UTC
- Message-ID
- <bc4789a0-ae80-c1dd-35b1-86949a807490@web.de>
- In-Reply-To
- <20210903170232.57646-3-carenas@gmail.com>
Am 03.09.21 um 19:02 schrieb Carlo Marcelo Arenas Belón:
Show 32 quoted lines
> In preparation to building with pedantic mode enabled, change a couple
> of places where the current mingw gcc compiler provided with the SDK
> reports issues.
>
> A full fix for the incompatible use of (void *) to store function
> pointers has been punted, with the minimal change to instead use a
> generic function pointer (FARPROC), and therefore the (hopefully)
> temporary need to disable incompatible pointer warnings.
>
> Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
> ---
> This is all that is needed to build cleanly once merged to maint/master/next
>
> There is at least one fix needed on top for seen, that was sent already
> and is expected as part of a different reroll as well of several more for
> git-for-windows/main that will be send independently.
>
> compat/nedmalloc/nedmalloc.c | 2 +-
> compat/win32/lazyload.h | 2 +-
> config.mak.dev | 13 ++++++++-----
> 3 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c
> index 1cc31c3502..edb438a777 100644
> --- a/compat/nedmalloc/nedmalloc.c
> +++ b/compat/nedmalloc/nedmalloc.c
> @@ -510,7 +510,7 @@ static void threadcache_free(nedpool *p, threadcache *tc, int mymspace, void *me
> assert(idx<=THREADCACHEMAXBINS);
> if(tck==*binsptr)
> {
> - fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", tck);
> + fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", (void *)tck);This change is not mentioned in the commit message. Clang on MacOS doesn't like the original code either and report if USE_NED_ALLOCATOR is enabled it reports:
compat/nedmalloc/nedmalloc.c:513:82: error: format specifies type 'void *' but the argument has type 'threadcacheblk *' (aka 'struct threadcacheblk_t *') [-Werror,-Wformat-pedantic]
fprintf(stderr, "Attempt to free already freed memory block %p - aborting!\n", tck);
~~ ^~~
This makes no sense to me, though: Any pointer can be converted to a
void pointer without a cast in C. GCC doesn't require void pointers
for %p even with -pedantic.A slightly shorter fix would be to replace "tck" with "mem". Not as obvious without further context, though.
René