diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-08-12 14:02:06 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2019-08-12 15:01:30 +0300 |
commit | a6799dc5b9ded442152b3430e321d9b147b9d7fd (patch) | |
tree | 66a490c03f995cea820c39f6ef0f84b925d027f3 /src/android/camera_hal_manager.cpp | |
parent | 667d8ea8fd4bda35e8888792d2b6c055fdb4be18 (diff) |
hal: Fix comparison of integers of different signs
The CameraHalManager::getCameraInfo() validates the camera id it
receives from the camera service, and in doing so compares it with an
unsigned integer, generating a compiler error:
src/android/camera_hal_manager.cpp:121:9: error: comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
if (id >= numCameras() || id < 0) {
~~ ^ ~~~~~~~~~~~~
Fix this by turning the id into an unsigned int, as camera ids can't be
negative. If a negative id is received from the camera service it will
be converted to a large unsigned integer that will fail the comparison
with numCameras().
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>
Diffstat (limited to 'src/android/camera_hal_manager.cpp')
-rw-r--r-- | src/android/camera_hal_manager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp index 08c759df..1e66f632 100644 --- a/src/android/camera_hal_manager.cpp +++ b/src/android/camera_hal_manager.cpp @@ -113,12 +113,12 @@ unsigned int CameraHalManager::numCameras() const return cameraManager_->cameras().size(); } -int CameraHalManager::getCameraInfo(int id, struct camera_info *info) +int CameraHalManager::getCameraInfo(unsigned int id, struct camera_info *info) { if (!info) return -EINVAL; - if (id >= numCameras() || id < 0) { + if (id >= numCameras()) { LOG(HAL, Error) << "Invalid camera id '" << id << "'"; return -EINVAL; } |