From a8428a57b15a2e1f993cbbda5969c7a85007dcc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 3 Jun 2021 16:26:36 +0200 Subject: [PATCH] pipewire: impl-module: simplify module dir handling logic Since `pw_split_walk()` does not skip leading runs of delimiters, if `module_dir` is an absolute path, then l = pw_split_strv(module_dir, "/", 0, &n_paths); will return an array of one element, which is exactly the same as `module_dir`, `strcmp(l[0], module_dir) == 0`. If `module_dir` is a relative path, then the returned array still contains a single element, which is, again, the same as `module_dir`. Therefore, omit the the call to `pw_split_strv()` and simply use `module_dir` as is. --- src/pipewire/impl-module.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/pipewire/impl-module.c b/src/pipewire/impl-module.c index f7aad9cbd..233373577 100644 --- a/src/pipewire/impl-module.c +++ b/src/pipewire/impl-module.c @@ -168,25 +168,15 @@ pw_context_load_module(struct pw_context *context, pw_impl_module_init_func_t init_func; module_dir = getenv("PIPEWIRE_MODULE_DIR"); - if (module_dir != NULL) { - char **l; - int i, n_paths; - + if (module_dir == NULL) { + module_dir = MODULEDIR; + pw_log_debug("moduledir set to: %s", module_dir); + } + else { pw_log_debug("PIPEWIRE_MODULE_DIR set to: %s", module_dir); - - l = pw_split_strv(module_dir, "/", 0, &n_paths); - for (i = 0; l[i] != NULL; i++) { - filename = find_module(l[i], name); - if (filename != NULL) - break; - } - pw_free_strv(l); - } else { - pw_log_debug("moduledir set to: %s", MODULEDIR); - - filename = find_module(MODULEDIR, name); } + filename = find_module(module_dir, name); if (filename == NULL) goto error_not_found;