[libcamera-devel] [PATCH v2 10/24] libcamera: controls: Catch type mismatch in ControlInfoMap
Niklas Söderlund
niklas.soderlund at ragnatech.se
Mon Nov 18 18:16:17 CET 2019
Hi Laurent,
Thanks for your work.
On 2019-11-08 22:53:55 +0200, Laurent Pinchart wrote:
> ControlInfoMap requires the ControlId and ControlRange of each entry to
> have identical types. Check for this and log an error if a mismatch is
> detected.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
> ---
> src/libcamera/controls.cpp | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
> index eae0250a92e3..c488b2e4eb3f 100644
> --- a/src/libcamera/controls.cpp
> +++ b/src/libcamera/controls.cpp
> @@ -571,8 +571,19 @@ ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const
> void ControlInfoMap::generateIdmap()
> {
> idmap_.clear();
> - for (const auto &ctrl : *this)
> +
> + for (const auto &ctrl : *this) {
> + if (ctrl.first->type() != ctrl.second.min().type()) {
> + LOG(Controls, Error)
> + << "Control " << utils::hex(ctrl.first->id())
> + << " type and range type mismatch";
> + idmap_.clear();
> + clear();
> + return;
> + }
> +
> idmap_[ctrl.first->id()] = ctrl.first;
> + }
> }
>
> /**
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list