Skip to content

Commit

Permalink
shared/plugin.c: fix incompatible function warning.
Browse files Browse the repository at this point in the history
  • Loading branch information
navi-desu authored and williamh committed Jul 22, 2024
1 parent 3277e65 commit a75b9dc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
26 changes: 7 additions & 19 deletions src/shared/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
Expand All @@ -91,17 +80,16 @@ 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);
} else {
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);
}
}
Expand Down
11 changes: 0 additions & 11 deletions src/shared/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a75b9dc

Please sign in to comment.