]> git.proxmox.com Git - proxmox.git/commitdiff
sys: clippy fixes
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 7 Dec 2021 10:41:25 +0000 (11:41 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 7 Dec 2021 10:42:53 +0000 (11:42 +0100)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
proxmox-sys/src/fs/read_dir.rs
proxmox-sys/src/fs/xattr.rs
proxmox-sys/src/linux/timer.rs

index 020f924debdb44851a53dd1d83fedfcbc4382b58..430372da47abe4ea7011dcff3c47f37a80eb0d34 100644 (file)
@@ -22,9 +22,9 @@ pub struct ReadDirEntry {
     parent_fd: RawFd,
 }
 
-impl Into<dir::Entry> for ReadDirEntry {
-    fn into(self) -> dir::Entry {
-        self.entry
+impl From<ReadDirEntry> for dir::Entry {
+    fn from(this: ReadDirEntry) -> dir::Entry {
+        this.entry
     }
 }
 
@@ -67,11 +67,18 @@ impl BorrowMut<dir::Entry> for ReadDirEntry {
 }
 
 impl ReadDirEntry {
+    /// Get the parent directory's file descriptor.
     #[inline]
     pub fn parent_fd(&self) -> RawFd {
         self.parent_fd
     }
 
+    /// Get the file name as a `&str`.
+    ///
+    /// # Safety
+    ///
+    /// It is up to the user to ensure that the file name is valid utf-8 *before* calling this
+    /// method.
     pub unsafe fn file_name_utf8_unchecked(&self) -> &str {
         std::str::from_utf8_unchecked(self.file_name().to_bytes())
     }
index 4763735671ad043c97c9e090fc77ccf8006b06f7..163a4119c24b4dd0646278eee7bcf14386ec978d 100644 (file)
@@ -135,9 +135,8 @@ pub fn fgetxattr(fd: RawFd, name: &CStr) -> Result<Vec<u8>, nix::errno::Errno> {
 
 /// Set an extended attribute on a file descriptor.
 pub fn fsetxattr(fd: RawFd, name: &CStr, data: &[u8]) -> Result<(), nix::errno::Errno> {
-    let flags = 0 as libc::c_int;
     let result = unsafe {
-        libc::fsetxattr(fd, name.as_ptr(), data.as_ptr() as *const libc::c_void, data.len(), flags)
+        libc::fsetxattr(fd, name.as_ptr(), data.as_ptr() as *const libc::c_void, data.len(), 0)
     };
     if result < 0 {
         return Err(Errno::last());
index 40877a197d0ccf75c9d902b1fceb723832951102..d18118ac7bc3228e61be37b04a2448f73b11f45a 100644 (file)
@@ -31,9 +31,9 @@ pub fn gettid() -> Tid {
 /// of...!
 pub struct Signal(c_int);
 
-impl Into<c_int> for Signal {
-    fn into(self) -> c_int {
-        self.0
+impl From<Signal> for c_int {
+    fn from(this: Signal) -> c_int {
+        this.0
     }
 }