libcamera: controls: Catch type mismatch in ControlInfoMap

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@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Laurent Pinchart 2019-10-27 23:51:02 +02:00
parent cdc68bf7f7
commit 7cbd88fec7

View file

@ -573,8 +573,19 @@ ControlInfoMap::const_iterator ControlInfoMap::find(unsigned int id) const
void ControlInfoMap::generateIdmap() void ControlInfoMap::generateIdmap()
{ {
idmap_.clear(); 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; idmap_[ctrl.first->id()] = ctrl.first;
}
} }
/** /**