From 8af2beccbd91c2f555eb5e5aa4f8e0455ab28eff Mon Sep 17 00:00:00 2001 From: Quentin Glidic Date: Fri, 2 Dec 2016 14:21:46 +0100 Subject: [PATCH] weston: Properly namespace modules entrypoint Signed-off-by: Quentin Glidic Reviewed-by: Daniel Stone --- compositor/cms-colord.c | 4 ++-- compositor/cms-static.c | 4 ++-- compositor/main.c | 27 +++++++++++++++++++-------- compositor/screen-share.c | 4 ++-- compositor/systemd-notify.c | 4 ++-- compositor/weston.h | 9 ++++++++- desktop-shell/shell.c | 4 ++-- fullscreen-shell/fullscreen-shell.c | 4 ++-- ivi-shell/ivi-layout.c | 4 +++- ivi-shell/ivi-shell.c | 4 ++-- tests/plugin-registry-test.c | 3 ++- tests/surface-global-test.c | 3 ++- tests/surface-screenshot.c | 4 ++-- tests/surface-test.c | 3 ++- tests/weston-test.c | 4 ++-- 15 files changed, 54 insertions(+), 31 deletions(-) diff --git a/compositor/cms-colord.c b/compositor/cms-colord.c index ae3ef25e..0daa2a7e 100644 --- a/compositor/cms-colord.c +++ b/compositor/cms-colord.c @@ -496,8 +496,8 @@ colord_cms_output_destroy(gpointer data) } WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]) { gboolean ret; GError *error = NULL; diff --git a/compositor/cms-static.c b/compositor/cms-static.c index a6bbfd46..e24501b6 100644 --- a/compositor/cms-static.c +++ b/compositor/cms-static.c @@ -91,8 +91,8 @@ cms_notifier_destroy(struct wl_listener *listener, void *data) WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]) { struct cms_static *cms; struct weston_output *output; diff --git a/compositor/main.c b/compositor/main.c index 2aa4936e..af093f13 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -761,7 +761,7 @@ weston_create_listening_socket(struct wl_display *display, const char *socket_na } WL_EXPORT void * -wet_load_module(const char *name, const char *entrypoint) +wet_load_module_entrypoint(const char *name, const char *entrypoint) { const char *builddir = getenv("WESTON_BUILD_DIR"); char path[PATH_MAX]; @@ -812,14 +812,28 @@ wet_load_module(const char *name, const char *entrypoint) return init; } + +WL_EXPORT int +wet_load_module(struct weston_compositor *compositor, + const char *name, int *argc, char *argv[]) +{ + int (*module_init)(struct weston_compositor *ec, + int *argc, char *argv[]); + + module_init = wet_load_module_entrypoint(name, "wet_module_init"); + if (!module_init) + return -1; + if (module_init(compositor, argc, argv) < 0) + return -1; + return 0; +} + static int load_modules(struct weston_compositor *ec, const char *modules, int *argc, char *argv[]) { const char *p, *end; char buffer[256]; - int (*module_init)(struct weston_compositor *ec, - int *argc, char *argv[]); if (modules == NULL) return 0; @@ -833,16 +847,13 @@ load_modules(struct weston_compositor *ec, const char *modules, if (wet_load_xwayland(ec) < 0) return -1; } else { - module_init = wet_load_module(buffer, "module_init"); - if (!module_init) - return -1; - if (module_init(ec, argc, argv) < 0) + if (wet_load_module(ec, buffer, argc, argv) < 0) return -1; } + p = end; while (*p == ',') p++; - } return 0; diff --git a/compositor/screen-share.c b/compositor/screen-share.c index 0db02036..bcb9defa 100644 --- a/compositor/screen-share.c +++ b/compositor/screen-share.c @@ -1106,8 +1106,8 @@ share_output_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t k } WL_EXPORT int -module_init(struct weston_compositor *compositor, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct screen_share *ss; struct weston_config *config = wet_get_config(compositor); diff --git a/compositor/systemd-notify.c b/compositor/systemd-notify.c index ce18ede9..50f03cbc 100644 --- a/compositor/systemd-notify.c +++ b/compositor/systemd-notify.c @@ -115,8 +115,8 @@ weston_compositor_destroy_listener(struct wl_listener *listener, void *data) } WL_EXPORT int -module_init(struct weston_compositor *compositor, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { char *watchdog_time_env; struct wl_event_loop *loop; diff --git a/compositor/weston.h b/compositor/weston.h index 2e0417c6..6229b34b 100644 --- a/compositor/weston.h +++ b/compositor/weston.h @@ -61,7 +61,14 @@ struct weston_config * wet_get_config(struct weston_compositor *compositor); void * -wet_load_module(const char *name, const char *entrypoint); +wet_load_module_entrypoint(const char *name, const char *entrypoint); + +int +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]); +int +wet_load_module(struct weston_compositor *compositor, + const char *name, int *argc, char *argv[]); int module_init(struct weston_compositor *compositor, diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c index 1b182110..5e109247 100644 --- a/desktop-shell/shell.c +++ b/desktop-shell/shell.c @@ -4874,8 +4874,8 @@ handle_seat_created(struct wl_listener *listener, void *data) } WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]) { struct weston_seat *seat; struct desktop_shell *shell; diff --git a/fullscreen-shell/fullscreen-shell.c b/fullscreen-shell/fullscreen-shell.c index af774747..d75c2396 100644 --- a/fullscreen-shell/fullscreen-shell.c +++ b/fullscreen-shell/fullscreen-shell.c @@ -897,8 +897,8 @@ bind_fullscreen_shell(struct wl_client *client, void *data, uint32_t version, } WL_EXPORT int -module_init(struct weston_compositor *compositor, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct fullscreen_shell *shell; struct weston_seat *seat; diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c index ada7a7c6..bbf1bcba 100644 --- a/ivi-shell/ivi-layout.c +++ b/ivi-shell/ivi-layout.c @@ -2120,7 +2120,9 @@ load_controller_modules(struct weston_compositor *compositor, const char *module end = strchrnul(p, ','); snprintf(buffer, sizeof buffer, "%.*s", (int)(end - p), p); - controller_module_init = wet_load_module(buffer, "controller_module_init"); + controller_module_init = + wet_load_module_entrypoint(buffer, + "controller_module_init"); if (!controller_module_init) return -1; diff --git a/ivi-shell/ivi-shell.c b/ivi-shell/ivi-shell.c index c8d59820..43329951 100644 --- a/ivi-shell/ivi-shell.c +++ b/ivi-shell/ivi-shell.c @@ -492,8 +492,8 @@ shell_add_bindings(struct weston_compositor *compositor, * Initialization of ivi-shell. */ WL_EXPORT int -module_init(struct weston_compositor *compositor, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct ivi_shell *shell; struct ivi_shell_setting setting = { }; diff --git a/tests/plugin-registry-test.c b/tests/plugin-registry-test.c index 2a32e01e..81e26cd8 100644 --- a/tests/plugin-registry-test.c +++ b/tests/plugin-registry-test.c @@ -89,7 +89,8 @@ runtime_tests(void *data) } WL_EXPORT int -module_init(struct weston_compositor *compositor, int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct wl_event_loop *loop; diff --git a/tests/surface-global-test.c b/tests/surface-global-test.c index 20d99ce9..4604d19d 100644 --- a/tests/surface-global-test.c +++ b/tests/surface-global-test.c @@ -80,7 +80,8 @@ surface_to_from_global(void *data) } WL_EXPORT int -module_init(struct weston_compositor *compositor, int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct wl_event_loop *loop; diff --git a/tests/surface-screenshot.c b/tests/surface-screenshot.c index 6ff2bfc5..716eedae 100644 --- a/tests/surface-screenshot.c +++ b/tests/surface-screenshot.c @@ -214,8 +214,8 @@ out: } WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]) { weston_compositor_add_debug_binding(ec, KEY_H, trigger_binding, ec); diff --git a/tests/surface-test.c b/tests/surface-test.c index 44630610..28520aaa 100644 --- a/tests/surface-test.c +++ b/tests/surface-test.c @@ -61,7 +61,8 @@ surface_transform(void *data) } WL_EXPORT int -module_init(struct weston_compositor *compositor, int *argc, char *argv[]) +wet_module_init(struct weston_compositor *compositor, + int *argc, char *argv[]) { struct wl_event_loop *loop; diff --git a/tests/weston-test.c b/tests/weston-test.c index e4dd36f0..2237c2ef 100644 --- a/tests/weston-test.c +++ b/tests/weston-test.c @@ -585,8 +585,8 @@ idle_launch_client(void *data) } WL_EXPORT int -module_init(struct weston_compositor *ec, - int *argc, char *argv[]) +wet_module_init(struct weston_compositor *ec, + int *argc, char *argv[]) { struct weston_test *test; struct wl_event_loop *loop;