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.
This commit is contained in:
Barnabás Pőcze 2021-06-03 16:26:36 +02:00
parent 0f03109cb6
commit a8428a57b1

View file

@ -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;