mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-23 16:45:07 +03:00
libcamera: base: shared_fd: Don't dup() an invalid fd
The SharedFD::dup() implementation calls the C library dup() function on
the fd. When the SharedFD instance is invalid, this produces an invalid
fd, which is the correct behaviour, but logs an error message.
Fix it by returning an invalid UniqueFD directly when the SharedFD is
invalid. This also saves a system call, which is always nice to do.
Fixes: fcf98514cb
("libcamera: base: file_descriptor: Return UniqueFD from dup()")
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
37c41aa6a6
commit
72679c682e
1 changed files with 3 additions and 0 deletions
|
@ -253,6 +253,9 @@ SharedFD &SharedFD::operator=(SharedFD &&other)
|
|||
*/
|
||||
UniqueFD SharedFD::dup() const
|
||||
{
|
||||
if (!isValid())
|
||||
return {};
|
||||
|
||||
UniqueFD dupFd(::dup(get()));
|
||||
if (!dupFd.isValid()) {
|
||||
int ret = -errno;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue