From 200bb4c60fa4bca408c94e5964f02de496401611 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 3 Oct 2019 23:57:12 +0300 Subject: libcamera: ipa_manager: Sort IPA modules by name Sort IPA modules by name when enumerating modules in a directory in order to guarantee a stable ordering. This eases debugging by making issues more reproducible. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/libcamera/ipa_manager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/libcamera/ipa_manager.cpp') diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 708233e8..27aa1792 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -7,6 +7,7 @@ #include "ipa_manager.h" +#include #include #include #include @@ -112,7 +113,7 @@ int IPAManager::addDir(const char *libDir) if (!dir) return -errno; - unsigned int count = 0; + std::vector paths; while ((ent = readdir(dir)) != nullptr) { int offset = strlen(ent->d_name) - 3; if (offset < 0) @@ -120,8 +121,16 @@ int IPAManager::addDir(const char *libDir) if (strcmp(&ent->d_name[offset], ".so")) continue; - IPAModule *ipaModule = new IPAModule(std::string(libDir) + - "/" + ent->d_name); + paths.push_back(std::string(libDir) + "/" + ent->d_name); + } + closedir(dir); + + /* Ensure a stable ordering of modules. */ + std::sort(paths.begin(), paths.end()); + + unsigned int count = 0; + for (const std::string &path : paths) { + IPAModule *ipaModule = new IPAModule(path); if (!ipaModule->isValid()) { delete ipaModule; continue; @@ -131,7 +140,6 @@ int IPAManager::addDir(const char *libDir) count++; } - closedir(dir); return count; } -- cgit v1.2.1