From patchwork Wed Sep 18 13:20:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1990 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 03DD460BB0 for ; Wed, 18 Sep 2019 15:20:27 +0200 (CEST) Received: from pendragon.ideasonboard.com (126.92.103.87.rev.vodafone.pt [87.103.92.126]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C189325; Wed, 18 Sep 2019 15:20:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568812827; bh=31nAMWL5WgPDLlMGKuCJK43Q35qID1gdICDoPu0PYFQ=; h=From:To:Cc:Subject:Date:From; b=oAIIAOqwKTxKVVm7ISil3CJ6V3OVmWR0o1PDlOROWO3vn/ibO+xVPoIzzjynOKh3z UClYYDuCbc/2LvQVCfpezLFC/eAkzj90oTXpMloviXo5o7NlbFPpJ1xUIYOaES48If xgXbh2dBNaNVGG4fdsypZxeXt6jGG2ct9u3klKN4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Sep 2019 16:20:14 +0300 Message-Id: <20190918132014.11412-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2] libcamera: ipa_manager: Rework error messages when enumerating IPAs X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Sep 2019 13:20:28 -0000 When enumerating IPAs, the system IPA directory and all the directories listed in the LIBCAMERA_IPA_MODULE_PATH environment variable are listed in turn. Failing to list any of those directories results in an error message being printed for every failure. This is particularly common when developing libcamera, as IPAs may not have been installed locally. To avoid unnecessarily worrying error messages, rework the enumeration procedure to only print a message when no IPA can be found at all. Individual missing directories are not considered as an issue anymore. The message is also downgraded from an error to a warning as the situation may still be normal. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder --- Changes since v1: - Only print a warning when LIBCAMERA_IPA_MODULE_PATH is not set if no module can be found in the system IPA directory - Add a new temporary paths variable to keep modulePaths unmodified for the warning message --- src/libcamera/ipa_manager.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/libcamera/ipa_manager.cpp b/src/libcamera/ipa_manager.cpp index 4276d995bdd5..270e538a4d01 100644 --- a/src/libcamera/ipa_manager.cpp +++ b/src/libcamera/ipa_manager.cpp @@ -33,26 +33,43 @@ LOG_DEFINE_CATEGORY(IPAManager) IPAManager::IPAManager() { - addDir(IPA_MODULE_DIR); + unsigned int ipaCount = 0; + int ret; + + ret = addDir(IPA_MODULE_DIR); + if (ret > 0) + ipaCount += ret; const char *modulePaths = utils::secure_getenv("LIBCAMERA_IPA_MODULE_PATH"); - if (!modulePaths) + if (!modulePaths) { + if (!ipaCount) + LOG(IPAManager, Warning) + << "No IPA found in '" IPA_MODULE_DIR "'"; return; + } + const char *paths = modulePaths; while (1) { - const char *delim = strchrnul(modulePaths, ':'); - size_t count = delim - modulePaths; + const char *delim = strchrnul(paths, ':'); + size_t count = delim - paths; if (count) { - std::string path(modulePaths, count); - addDir(path.c_str()); + std::string path(paths, count); + ret = addDir(path.c_str()); + if (ret > 0) + ipaCount += ret; } if (*delim == '\0') break; - modulePaths += count + 1; + paths += count + 1; } + + if (!ipaCount) + LOG(IPAManager, Warning) + << "No IPA found in '" IPA_MODULE_DIR "' and '" + << modulePaths << "'"; } IPAManager::~IPAManager() @@ -94,9 +111,6 @@ int IPAManager::addDir(const char *libDir) dir = opendir(libDir); if (!dir) { int ret = -errno; - LOG(IPAManager, Error) - << "Invalid path " << libDir << " for IPA modules: " - << strerror(-ret); return ret; }