diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
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.
Diffstat (limited to '')
| -rw-r--r-- | source/filter.c | 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 7 insertions, 2 deletions
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)); } /* |
