diff options
author | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-07-20 15:16:00 +0200 |
---|---|---|
committer | Anna (navi) Figueiredo Gomes <navi@vlhl.dev> | 2024-07-20 15:16:00 +0200 |
commit | 15de84d70ccd57afd7ad5af5cf95cef7fc542141 (patch) | |
tree | 7503973dac92c91eaf0ccaac946a4be46dfd7613 | |
parent | 1485cfb36cbdc2a079f73be16670cb3e64567852 (diff) |
shared/plugin.c: fix incompatible function warning.
Signed-off-by: Anna (navi) Figueiredo Gomes <navi@vlhl.dev>
-rw-r--r-- | src/shared/plugin.c | 26 | ||||
-rw-r--r-- | src/shared/plugin.h | 11 |
2 files changed, 7 insertions, 30 deletions
diff --git a/src/shared/plugin.c b/src/shared/plugin.c index f1338788..5cdfba8a 100644 --- a/src/shared/plugin.c +++ b/src/shared/plugin.c @@ -46,20 +46,6 @@ typedef struct plugin } PLUGIN; TAILQ_HEAD(, plugin) plugins; -#ifndef __FreeBSD__ -dlfunc_t -dlfunc(void * __restrict handle, const char * __restrict symbol) -{ - union { - void *d; - dlfunc_t f; - } rv; - - rv.d = dlsym(handle, symbol); - return rv.f; -} -#endif - void rc_plugin_load(void) { @@ -68,7 +54,10 @@ rc_plugin_load(void) PLUGIN *plugin; char *file = NULL; void *h; - int (*fptr)(RC_HOOK, const char *); + union { + void *sym; + int (*func)(RC_HOOK, const char *); + } fptr; /* Don't load plugins if we're in one */ if (rc_in_plugin) @@ -91,9 +80,8 @@ rc_plugin_load(void) continue; } - fptr = (int (*)(RC_HOOK, const char *)) - dlfunc(h, RC_PLUGIN_HOOK); - if (fptr == NULL) { + fptr.sym = dlsym(h, RC_PLUGIN_HOOK); + if (fptr.func == NULL) { eerror("%s: cannot find symbol `%s'", d->d_name, RC_PLUGIN_HOOK); dlclose(h); @@ -101,7 +89,7 @@ rc_plugin_load(void) plugin = xmalloc(sizeof(*plugin)); plugin->name = xstrdup(d->d_name); plugin->handle = h; - plugin->hook = fptr; + plugin->hook = fptr.func; TAILQ_INSERT_TAIL(&plugins, plugin, entries); } } diff --git a/src/shared/plugin.h b/src/shared/plugin.h index 3e458e23..b77f0ddc 100644 --- a/src/shared/plugin.h +++ b/src/shared/plugin.h @@ -32,15 +32,4 @@ void rc_plugin_load(void); void rc_plugin_unload(void); void rc_plugin_run(RC_HOOK, const char *value); -/* dlfunc defines needed to avoid ISO errors. FreeBSD has this right :) */ -#if !defined(__FreeBSD__) && !defined(__DragonFly__) -struct __dlfunc_arg { - int __dlfunc_dummy; -}; - -typedef void (*dlfunc_t)(struct __dlfunc_arg); - -dlfunc_t dlfunc (void * __restrict handle, const char * __restrict symbol); -#endif - #endif |