]> git.proxmox.com Git - pve-lxc-syscalld.git/blobdiff - src/tools.rs
clippy fixes
[pve-lxc-syscalld.git] / src / tools.rs
index 0447027638fe89777a5b83a7fb592b2143e95990..d3560702006016f32665f026088f62deb23c9f70 100644 (file)
@@ -3,7 +3,7 @@
 //! Note that this should stay small, otherwise we should introduce a dependency on our `proxmox`
 //! crate as that's where we have all this stuff usually...
 
-use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
+use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd};
 
 pub fn set_fd_nonblocking<T: AsRawFd + ?Sized>(fd: &T, on: bool) -> nix::Result<libc::c_int> {
     use nix::fcntl;
@@ -13,33 +13,6 @@ pub fn set_fd_nonblocking<T: AsRawFd + ?Sized>(fd: &T, on: bool) -> nix::Result<
     fcntl::fcntl(fd, fcntl::FcntlArg::F_SETFL(flags))
 }
 
-/// Guard a raw file descriptor with a drop handler. This is mostly useful when access to an owned
-/// `RawFd` is required without the corresponding handler object (such as when only the file
-/// descriptor number is required in a closure which may be dropped instead of being executed).
-#[repr(transparent)]
-pub struct Fd(pub RawFd);
-
-file_descriptor_impl!(Fd);
-
-impl FromRawFd for Fd {
-    unsafe fn from_raw_fd(fd: RawFd) -> Self {
-        Self(fd)
-    }
-}
-
-impl Fd {
-    pub fn set_nonblocking(&mut self, nb: bool) -> nix::Result<libc::c_int> {
-        set_fd_nonblocking(self, nb)
-    }
-}
-
-impl AsRef<RawFd> for Fd {
-    #[inline]
-    fn as_ref(&self) -> &RawFd {
-        &self.0
-    }
-}
-
 /// Byte vector utilities.
 pub mod vec {
     /// Create an uninitialized byte vector of a specific size.
@@ -60,7 +33,7 @@ pub mod vec {
     pub unsafe fn uninitialized(len: usize) -> Vec<u8> {
         unsafe {
             let data = std::alloc::alloc(std::alloc::Layout::array::<u8>(len).unwrap());
-            Vec::from_raw_parts(data as *mut u8, len, len)
+            Vec::from_raw_parts(data, len, len)
         }
     }
 }