From patchwork Fri Nov 8 20:53:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2306 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 342AD61373 for ; Fri, 8 Nov 2019 21:54:26 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CF2362D1 for ; Fri, 8 Nov 2019 21:54:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1573246465; bh=rvel1WbwIi38a5JoPv5cDk5BY2zcxawNIjeP/GSlCEg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=DmlL921pe8Bwp+k5qeFK3B3lWnyJMkriX7OjZSl8oXxAoLrEQur1GqRbOlsLJDxUr x6aPMZBtPFHbEsuEvOaKJnM+07lMpBJt883aPOLAdocU7LyM/OCRkRT2CYc79rTVY4 sKqPFxphygv4lpEQJyov+NJ9E1IJEXPJ62GlVMBU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 8 Nov 2019 22:53:55 +0200 Message-Id: <20191108205409.18845-11-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108205409.18845-1-laurent.pinchart@ideasonboard.com> References: <20191108205409.18845-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 10/24] libcamera: controls: Catch type mismatch in ControlInfoMap X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Nov 2019 20:54:27 -0000 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 Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- 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; + } } /**