Re: [PATCH v3 2/3] win32: allow building with pedantic mode enabled
From: René Scharfe <hidden>
Date: 2021-09-03 18:47:45
Am 03.09.21 um 19:02 schrieb Carlo Marcelo Arenas Belón:
quoted hunk ↗ jump to hunk
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 <redacted> --- 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é