From 0bfd77ff5b97241e46d307d59b3a2d89995b03ce Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:23:56 -1000 Subject: Pass callbacks to git by address ISO C has no conversion between a function pointer and void *, so the callbacks handed through git's data pointers and the write found by dlsym stopped the pedantic half of a DEVELOPER=1 build. --- source/filter.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/filter.c') diff --git a/source/filter.c b/source/filter.c index 3ffd077..5f96cc0 100644 --- a/source/filter.c +++ b/source/filter.c @@ -150,9 +150,14 @@ static struct cgit_filter *current_write_filter = NULL; void cgit_init_filters(void) { - libc_write = dlsym(RTLD_NEXT, "write"); - if (!libc_write) + void *symbol = dlsym(RTLD_NEXT, "write"); + + if (!symbol) die("Unable to find libc's write function"); + // ISO C cannot convert an object pointer to a function pointer, while + // POSIX guarantees the two share a representation, so the bytes are + // copied across instead. + memcpy(&libc_write, &symbol, sizeof(libc_write)); } /* -- cgit