mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-16 08:55:06 +03:00
libcamera: v4l2_videodevice: Fix potential errno overwrite
The errno variable can potentially be overwritten by operator<<(). Store it in a local variable before logging the error message. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
This commit is contained in:
parent
b90faccb2c
commit
f9e2df9519
1 changed files with 6 additions and 3 deletions
|
@ -647,14 +647,17 @@ int V4L2VideoDevice::open()
|
|||
*/
|
||||
int V4L2VideoDevice::open(SharedFD handle, enum v4l2_buf_type type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
UniqueFD newFd = handle.dup();
|
||||
if (!newFd.isValid()) {
|
||||
ret = -errno;
|
||||
LOG(V4L2, Error) << "Failed to duplicate file handle: "
|
||||
<< strerror(errno);
|
||||
return -errno;
|
||||
<< strerror(-ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ret = V4L2Device::setFd(std::move(newFd));
|
||||
ret = V4L2Device::setFd(std::move(newFd));
|
||||
if (ret < 0) {
|
||||
LOG(V4L2, Error) << "Failed to set file handle: "
|
||||
<< strerror(-ret);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue