summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2022-12-06 14:23:01 +0100
committerJacopo Mondi <jacopo@jmondi.org>2022-12-09 08:57:41 +0100
commit35f925b9dff8887f833ea880b336caecf855eba8 (patch)
tree47951d75a3c99df6cc43cb808ae1c606ddd41539
parent870a3bde3d1fd8fe416b6d1d3dd5e7b92fbde174 (diff)
android: Be verbose when failing in parsing config
Add error messages to the Camera HAL configuration file parsing routine. Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--src/android/camera_hal_config.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/android/camera_hal_config.cpp b/src/android/camera_hal_config.cpp
index 0942263c..b2047e26 100644
--- a/src/android/camera_hal_config.cpp
+++ b/src/android/camera_hal_config.cpp
@@ -67,24 +67,40 @@ int CameraHalConfig::Private::parseConfigFile(File &file,
cameras_ = cameras;
std::unique_ptr<YamlObject> root = YamlParser::parse(file);
- if (!root)
+ if (!root) {
+ LOG(HALConfig, Error) << "Failed to parse " << file.fileName()
+ << ": not a valid yaml file";
return -EINVAL;
+ }
- if (!root->isDictionary())
+ if (!root->isDictionary()) {
+ LOG(HALConfig, Error) << "Failed to parse " << file.fileName()
+ << ": not a dictionary";
return -EINVAL;
+ }
/* Parse property "cameras" */
- if (!root->contains("cameras"))
+ if (!root->contains("cameras")) {
+ LOG(HALConfig, Error) << "Failed to parse " << file.fileName()
+ << ": missing 'cameras' property";
return -EINVAL;
+ }
const YamlObject &yamlObjectCameras = (*root)["cameras"];
- if (!yamlObjectCameras.isDictionary())
+ if (!yamlObjectCameras.isDictionary()) {
+ LOG(HALConfig, Error) << "Failed to parse " << file.fileName()
+ << ": malformed 'cameras' dictionary";
return -EINVAL;
+ }
for (const auto &[cameraId, configData] : yamlObjectCameras.asDict()) {
- if (parseCameraConfigData(cameraId, configData))
+ if (parseCameraConfigData(cameraId, configData)) {
+ LOG(HALConfig, Error) << "Failed to parse " << file.fileName()
+ << ": invalid camera entry: "
+ << cameraId;
return -EINVAL;
+ }
}
return 0;