v4l2: v4l2_camera_proxy: Fix sign compare compilation error

When compiling for ARM and uClibc, gcc-8.3.0 complains about comparison
of integer expressions of different signedness:

../../src/v4l2/v4l2_camera_proxy.cpp: In member function ‘void* V4L2CameraProxy::mmap(void*, size_t, int, int, off_t)’:
../../src/v4l2/v4l2_camera_proxy.cpp:88:25: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘off_t’ {aka ‘long int’} [-Werror=sign-compare]
  if (index * sizeimage_ != offset || length != sizeimage_) {
      ~~~~~~~~~~~~~~~~~~~^~~~~~~~~

Fix the compilation error with a cast.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
This commit is contained in:
Laurent Pinchart 2020-03-07 22:20:45 +02:00
parent 20fb72a56e
commit 1268751ce6

View file

@ -85,7 +85,8 @@ void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags,
} }
unsigned int index = offset / sizeimage_; unsigned int index = offset / sizeimage_;
if (index * sizeimage_ != offset || length != sizeimage_) { if (static_cast<off_t>(index * sizeimage_) != offset ||
length != sizeimage_) {
errno = EINVAL; errno = EINVAL;
return MAP_FAILED; return MAP_FAILED;
} }