sys: clippy fixes

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-12-07 11:41:25 +01:00
parent e888fa5181
commit c280f73793
3 changed files with 14 additions and 8 deletions

View 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())
}

View 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());

View 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
}
}