From 6dcbb538f6f50a6ebc27b1e27217af39ecadda0b Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 21 Sep 2023 21:01:37 -0700 Subject: [PATCH] Take `OwnedFd` instead of `RawFd` as argument to `receive_to_fd` This appears to be the only use of `RawFd` in a public API. With this change, these functions should be safe to call. I'm not sure if it would make more sense for these functions to not close the file descriptor. In which case they could take `BorrowedFd`. But this matches the current implementation, but with an IO safe type. --- CHANGELOG.md | 1 + src/data_device_manager/data_offer.rs | 10 ++++------ src/primary_selection/offer.rs | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4e6b8a11..31bd80153 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `xkeysym::Keysym` is used as a keyboard key representation instead of `u32` - `wayland-rs` dependencies are updated to 0.31 - `calloop` dependency updated to 0.12.1 +- Take `OwnedFd` instead of `RawFd` as argument to `receive_to_fd` functions. #### Fixed diff --git a/src/data_device_manager/data_offer.rs b/src/data_device_manager/data_offer.rs index 7a3ef4f26..9b42c0c12 100644 --- a/src/data_device_manager/data_offer.rs +++ b/src/data_device_manager/data_offer.rs @@ -1,6 +1,6 @@ use std::{ ops::{Deref, DerefMut}, - os::unix::prelude::{BorrowedFd, FromRawFd, RawFd}, + os::unix::prelude::{AsFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}, sync::{Arc, Mutex}, }; @@ -427,16 +427,14 @@ pub fn receive(offer: &WlDataOffer, mime_type: String) -> std::io::Result