libcamera: base: file_descriptor: Return UniqueFD from dup()
The dup() function returns a duplicate of the file descriptor. Wrapping it in a FileDescriptor isn't wrong as such, but it prevents from using it in contexts where a UniqueFD is needed. As the duplicate is guaranteed to have a single owner when created, return it as a UniqueFD instead. A FileDescriptor can easily be created from the UniqueFD if desired. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
bool isValid() const { return fd_ != nullptr; }
|
||||
int fd() const { return fd_ ? fd_->fd() : -1; }
|
||||
FileDescriptor dup() const;
|
||||
UniqueFD dup() const;
|
||||
|
||||
private:
|
||||
class Descriptor
|
||||
|
||||
Reference in New Issue
Block a user