Use correct function casts. Use dlfunc where available to remove ISO warnings :)
This commit is contained in:
parent
b2e8324184
commit
d0308aaecd
@ -23,7 +23,7 @@ typedef struct plugin
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
void *handle;
|
void *handle;
|
||||||
int (*hook) (rc_hook_t hook, const char *name);
|
int (*hook) (rc_hook_t, const char *);
|
||||||
struct plugin *next;
|
struct plugin *next;
|
||||||
} plugin_t;
|
} plugin_t;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ void rc_plugin_load (void)
|
|||||||
char *p = rc_strcatpaths (RC_PLUGINDIR, file, NULL);
|
char *p = rc_strcatpaths (RC_PLUGINDIR, file, NULL);
|
||||||
void *h = dlopen (p, RTLD_LAZY);
|
void *h = dlopen (p, RTLD_LAZY);
|
||||||
char *func;
|
char *func;
|
||||||
void *f;
|
int (*fptr) (rc_hook_t, const char *);
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (! h) {
|
if (! h) {
|
||||||
@ -62,8 +62,12 @@ void rc_plugin_load (void)
|
|||||||
func = rc_xmalloc (sizeof (char *) * len);
|
func = rc_xmalloc (sizeof (char *) * len);
|
||||||
snprintf (func, len, "_%s_hook", file);
|
snprintf (func, len, "_%s_hook", file);
|
||||||
|
|
||||||
f = dlsym (h, func);
|
#ifdef __FreeBSD__
|
||||||
if (! f) {
|
fptr = (int (*)(rc_hook_t, const char*)) dlfunc (h, func);
|
||||||
|
#else
|
||||||
|
fptr = (int (*)(rc_hook_t, const char*)) dlsym (h, func);
|
||||||
|
#endif
|
||||||
|
if (! fptr) {
|
||||||
eerror ("`%s' does not expose the symbol `%s'", p, func);
|
eerror ("`%s' does not expose the symbol `%s'", p, func);
|
||||||
dlclose (h);
|
dlclose (h);
|
||||||
} else {
|
} else {
|
||||||
@ -76,7 +80,7 @@ void rc_plugin_load (void)
|
|||||||
memset (plugin, 0, sizeof (plugin_t));
|
memset (plugin, 0, sizeof (plugin_t));
|
||||||
plugin->name = rc_xstrdup (file);
|
plugin->name = rc_xstrdup (file);
|
||||||
plugin->handle = h;
|
plugin->handle = h;
|
||||||
plugin->hook = f;
|
plugin->hook = fptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
free (func);
|
free (func);
|
||||||
|
@ -80,8 +80,8 @@ static void setup_selinux (int argc, char **argv)
|
|||||||
* which sucks ass
|
* which sucks ass
|
||||||
* http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html
|
* http://www.opengroup.org/onlinepubs/009695399/functions/dlsym.html
|
||||||
*/
|
*/
|
||||||
selinux_run_init_old = dlsym (lib_handle, "selinux_runscript");
|
selinux_run_init_old = (void (*)(void)) dlsym (lib_handle, "selinux_runscript");
|
||||||
selinux_run_init_new = dlsym (lib_handle, "selinux_runscript2");
|
selinux_run_init_new = (void (*)(int, char **)) dlsym (lib_handle, "selinux_runscript2");
|
||||||
|
|
||||||
/* Use new run_init if it rc_exists, else fall back to old */
|
/* Use new run_init if it rc_exists, else fall back to old */
|
||||||
if (selinux_run_init_new)
|
if (selinux_run_init_new)
|
||||||
|
Loading…
Reference in New Issue
Block a user