This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=1fbd68e425224e1e2163a2bb52d666fceec3659e commit 1fbd68e425224e1e2163a2bb52d666fceec3659e (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Tue Dec 6 19:32:47 2022 +0100 libcompat: Use an union to track chunkfun and freefun These member functions are "overloaded" and can take one or two arguments depending on the use_extra_arg member. Use an union with two members, one for each function prototype. Warned-by: gcc -Wcast-function-type on musl-libc --- lib/compat/obstack.c | 16 ++++++++-------- lib/compat/obstack.h | 14 ++++++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/compat/obstack.c b/lib/compat/obstack.c index 381b7f9a5..dad7c36c5 100644 --- a/lib/compat/obstack.c +++ b/lib/compat/obstack.c @@ -123,15 +123,15 @@ compat_symbol (libc, _obstack_compat, _obstack, GLIBC_2_0); # define CALL_CHUNKFUN(h, size) \ (((h) -> use_extra_arg) \ - ? (*(h)->chunkfun) ((h)->extra_arg, (size)) \ - : (*(struct _obstack_chunk *(*) (size_t)) (h)->chunkfun) ((size))) + ? (*(h)->chunkfun.arg2) ((h)->extra_arg, (size)) \ + : (*(h)->chunkfun.arg1) ((size))) # define CALL_FREEFUN(h, old_chunk) \ do { \ if ((h) -> use_extra_arg) \ - (*(h)->freefun) ((h)->extra_arg, (old_chunk)); \ + (*(h)->freefun.arg2) ((h)->extra_arg, (old_chunk)); \ else \ - (*(void (*) (void *)) (h)->freefun) ((old_chunk)); \ + (*(h)->freefun.arg1) ((old_chunk)); \ } while (0) @@ -170,8 +170,8 @@ _obstack_begin (struct obstack *h, size = 4096 - extra; } - h->chunkfun = (struct _obstack_chunk * (*)(void *, size_t)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; + h->chunkfun.arg1 = chunkfun; + h->freefun.arg1 = freefun; h->chunk_size = size; h->alignment_mask = alignment - 1; h->use_extra_arg = 0; @@ -217,8 +217,8 @@ _obstack_begin_1 (struct obstack *h, size_t size, size_t alignment, size = 4096 - extra; } - h->chunkfun = (struct _obstack_chunk * (*)(void *, size_t)) chunkfun; - h->freefun = (void (*) (void *, struct _obstack_chunk *)) freefun; + h->chunkfun.arg2 = chunkfun; + h->freefun.arg2 = freefun; h->chunk_size = size; h->alignment_mask = alignment - 1; h->extra_arg = arg; diff --git a/lib/compat/obstack.h b/lib/compat/obstack.h index 174c7d6ef..8bed79315 100644 --- a/lib/compat/obstack.h +++ b/lib/compat/obstack.h @@ -163,8 +163,14 @@ struct obstack /* control current object in current chunk */ /* These prototypes vary based on `use_extra_arg', and we use casts to the prototypeless function type in all assignments, but having prototypes here quiets -Wstrict-prototypes. */ - struct _obstack_chunk *(*chunkfun) (void *, long); - void (*freefun) (void *, struct _obstack_chunk *); + union { + void *(*arg1) (size_t); + void *(*arg2) (void *, size_t); + } chunkfun; + union { + void (*arg1) (void *); + void (*arg2) (void *, void *); + } freefun; void *extra_arg; /* first arg for chunk alloc/dealloc funcs */ unsigned use_extra_arg:1; /* chunk alloc/dealloc funcs take extra arg */ unsigned maybe_empty_object:1;/* There is a possibility that the current @@ -243,10 +249,10 @@ extern int obstack_exit_failure; (void (*) (void *, void *)) (freefun), (arg)) #define obstack_chunkfun(h, newchunkfun) \ - ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun)) + ((h) -> chunkfun.arg2 = (struct _obstack_chunk *(*)(void *, size_t)) (newchunkfun)) #define obstack_freefun(h, newfreefun) \ - ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) + ((h) -> freefun.arg2 = (void (*)(void *, struct _obstack_chunk *)) (newfreefun)) #define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = (achar)) -- Dpkg.Org's dpkg

