From 35f925b9dff8887f833ea880b336caecf855eba8 Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Tue, 6 Dec 2022 14:23:01 +0100 Subject: android: Be verbose when failing in parsing config Add error messages to the Camera HAL configuration file parsing routine. Signed-off-by: Jacopo Mondi --- src/android/camera_hal_config.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src') 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 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; -- cgit v1.2.1