diff options
author | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-02-21 11:55:49 +0000 |
---|---|---|
committer | Kieran Bingham <kieran.bingham@ideasonboard.com> | 2020-02-24 09:36:46 +0000 |
commit | 80d70e4fcf6c8aa92c3097414b90325e855bab6e (patch) | |
tree | d1544565a14f9d45aaa23fbb961b638648f47877 | |
parent | 7860977710f4365557f35aa19f2dc5f150030de3 (diff) |
libcamera: ipa_manager: Simplify addDir() usage
The addDir call only returns an error if it can't open the directory.
Callers only care about the number of modules added, and discard any
error information.
Simplify the return value and calling code by returning an unsigned int
of the number of modules loaded.
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r-- | src/libcamera/include/ipa_manager.h | 2 | ||||
-rw-r--r-- | src/libcamera/ipa_manager.cpp | 16 |
2 files changed, 6 insertions, 12 deletions
diff --git a/src/libcamera/include/ipa_manager.h b/src/libcamera/include/ipa_manager.h index 126f8bab..f13a93d7 100644 --- a/src/libcamera/include/ipa_manager.h +++ b/src/libcamera/include/ipa_manager.h @@ -32,7 +32,7 @@ private: IPAManager(); ~IPAManager(); - int addDir(const char *libDir); + unsigned int addDir(const char *libDir); }; } /* namespace libcamera */ diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 7f0a5d58..90dd3003 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -96,7 +96,6 @@ LOG_DEFINE_CATEGORY(IPAManager) IPAManager::IPAManager() { unsigned int ipaCount = 0; - int ret; /* User-specified paths take precedence. */ const char *modulePaths = utils::secure_getenv("LIBCAMERA_IPA_MODULE_PATH"); @@ -105,9 +104,7 @@ IPAManager::IPAManager() if (dir.empty()) continue; - int ret = addDir(dir.c_str()); - if (ret > 0) - ipaCount += ret; + ipaCount += addDir(dir.c_str()); } if (!ipaCount) @@ -116,9 +113,7 @@ IPAManager::IPAManager() } /* Load IPAs from the installed system path. */ - ret = addDir(IPA_MODULE_DIR); - if (ret > 0) - ipaCount += ret; + ipaCount += addDir(IPA_MODULE_DIR); if (!ipaCount) LOG(IPAManager, Warning) @@ -153,17 +148,16 @@ IPAManager *IPAManager::instance() * This method tries to create an IPAModule instance for every shared object * found in \a libDir, and skips invalid IPA modules. * - * \return Number of modules loaded by this call, or a negative error code - * otherwise + * \return Number of modules loaded by this call */ -int IPAManager::addDir(const char *libDir) +unsigned int IPAManager::addDir(const char *libDir) { struct dirent *ent; DIR *dir; dir = opendir(libDir); if (!dir) - return -errno; + return 0; std::vector<std::string> paths; while ((ent = readdir(dir)) != nullptr) { |