<html><head></head><body>Hi,<br><br>It was a string with a string comparison before (inside vlc_dlsym). It still is a string comparison.<br><br>Of course it could be changed to an integer, but then the meta export macro won't be usable, so it will need more custom code.<br><br><div class="gmail_quote">Le 19 juillet 2019 10:04:48 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2019-07-18 21:29, Rémi Denis-Courmont wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><hr> src/modules/bank.c | 59 +++++++++++++++++++++++++++++++++++-----------<br> 1 file changed, 45 insertions(+), 14 deletions(-)<br><br>diff --git a/src/modules/bank.c b/src/modules/bank.c<br>index 0b551a91bc..f6f5ae1a85 100644<br>--- a/src/modules/bank.c<br>+++ b/src/modules/bank.c<br>@@ -193,6 +193,49 @@ static void module_InitStaticModules(void) { }<br> #endif<br> <br> #ifdef HAVE_DYNAMIC_PLUGINS<br>+static const char *module_GetVersion(void *handle)<br>+{<br>+ const char *(*get_api_version)(void);<br>+<br>+ get_api_version = vlc_dlsym(handle, "vlc_entry_api_version");<br>+ if (get_api_version == NULL)<br>+ return NULL;<br>+<br>+ return get_api_version();<br>+}<br>+<br>+static void *module_Open(struct vlc_logger *log,<br>+ const char *path, bool fast)<br>+{<br>+ void *handle = vlc_dlopen(path, fast);<br>+ if (handle == NULL)<br>+ {<br>+ char *errmsg = vlc_dlerror();<br>+<br>+ vlc_error(log, "cannot load plug-in %s: %s", path,<br>+ errmsg ? errmsg : "unknown error");<br>+ free(errmsg);<br>+ return NULL;<br>+ }<br>+<br>+ const char *str = module_GetVersion(handle);<br>+ if (str == NULL) {<br>+ vlc_error(log, "cannot load plug-in %s: %s", path,<br>+ "unknown version or not a plug-in");<br>+error:<br>+ vlc_dlclose(handle);<br>+ return NULL;<br>+ }<br>+<br>+ if (strcmp(str, VLC_API_VERSION_STRING)) {<br></blockquote><br>Couldn't we use an integer ? Speed-wise this is going backward from have <br>no extra check needed because the name we loaded already had the proper <br>version, which was a feature not a bug.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">+ vlc_error(log, "cannot load plug-in %s: unsupported version %s", path,<br>+ str);<br>+ goto error;<br>+ }<br>+<br>+ return handle;<br>+}<br>+<br> static const char vlc_entry_name[] = "vlc_entry" MODULE_SUFFIX;<br> <br> /**<br>@@ -207,15 +250,9 @@ static const char vlc_entry_name[] = "vlc_entry" MODULE_SUFFIX;<br> static vlc_plugin_t *module_InitDynamic(vlc_object_t *obj, const char *path,<br> bool fast)<br> {<br>- void *handle = vlc_dlopen(path, fast);<br>+ void *handle = module_Open(obj->logger, path, fast);<br> if (handle == NULL)<br>- {<br>- char *errmsg = vlc_dlerror();<br>- msg_Err(obj, "cannot load plug-in %s: %s", path,<br>- errmsg ? errmsg : "unknown error");<br>- free(errmsg);<br> return NULL;<br>- }<br> <br> /* Try to resolve the symbol */<br> vlc_plugin_cb entry = vlc_dlsym(handle, vlc_entry_name);<br>@@ -507,15 +544,9 @@ int module_Map(struct vlc_logger *log, vlc_plugin_t *plugin)<br> /* Try to load the plug-in (without locks, so read-only) */<br> assert(plugin->abspath != NULL);<br> <br>- void *handle = vlc_dlopen(plugin->abspath, false);<br>+ void *handle = module_Open(log, plugin->abspath, false);<br> if (handle == NULL)<br>- {<br>- char *errmsg = vlc_dlerror();<br>- vlc_error(log, "cannot load plug-in %s: %s",<br>- plugin->abspath, errmsg ? errmsg : "unknown error");<br>- free(errmsg);<br> return -1;<br>- }<br> <br> vlc_plugin_cb entry = vlc_dlsym(handle, vlc_entry_name);<br> if (entry == NULL)<br>-- <br>2.22.0<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>