summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo@jmondi.org>2020-02-27 14:41:21 +0100
committerJacopo Mondi <jacopo@jmondi.org>2020-03-20 15:12:21 +0100
commite0808528d855dd6f4a82ee4a569a86cf6e45f532 (patch)
tree143a83d7e690600928bbfdab7a0378418454f1df
parentad5d123578ca5b0cd8ed43a8d21a62cc55422870 (diff)
libcamera: v4l2_controls: Fix usage of strerror()
On failure, the return code from V4L2Device::ioctl() is the negative error code set by the failed ::ioctl() system call. When the return code of V4L2Device::ioctl() is provided to strerror() it has to be negated again to obtain the positive error code. Fix a few wrong usages of the return code which provided to the strerror() function a negative error code. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
-rw-r--r--src/libcamera/v4l2_device.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp
index 1698d245..475572bb 100644
--- a/src/libcamera/v4l2_device.cpp
+++ b/src/libcamera/v4l2_device.cpp
@@ -201,13 +201,13 @@ int V4L2Device::getControls(ControlList *ctrls)
/* Generic validation error. */
if (errorIdx == 0 || errorIdx >= count) {
LOG(V4L2, Error) << "Unable to read controls: "
- << strerror(ret);
+ << strerror(-ret);
return -EINVAL;
}
/* A specific control failed. */
LOG(V4L2, Error) << "Unable to read control " << errorIdx
- << ": " << strerror(ret);
+ << ": " << strerror(-ret);
count = errorIdx - 1;
ret = errorIdx;
}
@@ -291,13 +291,13 @@ int V4L2Device::setControls(ControlList *ctrls)
/* Generic validation error. */
if (errorIdx == 0 || errorIdx >= count) {
LOG(V4L2, Error) << "Unable to set controls: "
- << strerror(ret);
+ << strerror(-ret);
return -EINVAL;
}
/* A specific control failed. */
LOG(V4L2, Error) << "Unable to set control " << errorIdx
- << ": " << strerror(ret);
+ << ": " << strerror(-ret);
count = errorIdx - 1;
ret = errorIdx;
}