Skip to content

Commit 4f3dd21

Browse files
liubogithubjiangliu
authored andcommitted
Fix clippy errors
This fixes warnings/errors in the code base according to cargo 1.66.0's clippy. Signed-off-by: Liu Bo <[email protected]>
1 parent 383bbe0 commit 4f3dd21

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

src/abi/fuse_abi.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,16 @@ impl Attr {
600600
atimensec: st.st_atime_nsec as u32,
601601
mtimensec: st.st_mtime_nsec as u32,
602602
ctimensec: st.st_ctime_nsec as u32,
603+
#[cfg(target_os = "linux")]
604+
mode: st.st_mode,
605+
#[cfg(target_os = "macos")]
603606
mode: st.st_mode as u32,
604607
nlink: st.st_nlink as u32,
605608
uid: st.st_uid,
606609
gid: st.st_gid,
607610
rdev: st.st_rdev as u32,
608611
blksize: st.st_blksize as u32,
609-
flags: flags as u32,
612+
flags,
610613
#[cfg(target_os = "macos")]
611614
crtime: 0,
612615
#[cfg(target_os = "macos")]
@@ -658,6 +661,22 @@ pub struct Kstatfs {
658661
unsafe impl ByteValued for Kstatfs {}
659662

660663
impl From<statvfs64> for Kstatfs {
664+
#[cfg(target_os = "linux")]
665+
fn from(st: statvfs64) -> Self {
666+
Kstatfs {
667+
blocks: st.f_blocks,
668+
bfree: st.f_bfree,
669+
bavail: st.f_bavail,
670+
files: st.f_files,
671+
ffree: st.f_ffree,
672+
bsize: st.f_bsize as u32,
673+
namelen: st.f_namemax as u32,
674+
frsize: st.f_frsize as u32,
675+
..Default::default()
676+
}
677+
}
678+
679+
#[cfg(target_os = "macos")]
661680
fn from(st: statvfs64) -> Self {
662681
Kstatfs {
663682
blocks: st.f_blocks as u64,
@@ -745,7 +764,7 @@ impl From<u32> for Opcode {
745764
if op >= Opcode::MaxOpcode as u32 {
746765
return Opcode::MaxOpcode;
747766
}
748-
unsafe { mem::transmute(op as u32) }
767+
unsafe { mem::transmute(op) }
749768
}
750769
}
751770

src/api/pseudo_fs.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,14 @@ impl PseudoFs {
258258
..Default::default()
259259
};
260260
attr.ino = ino;
261-
attr.mode = (libc::S_IFDIR | libc::S_IRWXU | libc::S_IRWXG | libc::S_IRWXO) as u32;
261+
#[cfg(target_os = "linux")]
262+
{
263+
attr.mode = libc::S_IFDIR | libc::S_IRWXU | libc::S_IRWXG | libc::S_IRWXO;
264+
}
265+
#[cfg(target_os = "macos")]
266+
{
267+
attr.mode = (libc::S_IFDIR | libc::S_IRWXU | libc::S_IRWXG | libc::S_IRWXO) as u32;
268+
}
262269
let now = SystemTime::now();
263270
attr.ctime = now
264271
.duration_since(SystemTime::UNIX_EPOCH)

src/api/server/sync_io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ impl<F: FileSystem + Sync> Server<F> {
284284

285285
#[cfg(target_os = "linux")]
286286
let flags =
287-
flags & (libc::RENAME_EXCHANGE | libc::RENAME_NOREPLACE | libc::RENAME_WHITEOUT) as u32;
287+
flags & (libc::RENAME_EXCHANGE | libc::RENAME_NOREPLACE | libc::RENAME_WHITEOUT);
288288

289289
#[cfg(target_os = "macos")]
290-
let flags = flags & (libc::RENAME_EXCL | libc::RENAME_SWAP) as u32;
290+
let flags = flags & (libc::RENAME_EXCL | libc::RENAME_SWAP);
291291

292292
self.do_rename(ctx, size_of::<Rename2In>(), newdir, flags)
293293
}

src/api/vfs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl Vfs {
286286
/// Create a new vfs instance
287287
pub fn new(opts: VfsOptions) -> Self {
288288
Vfs {
289-
next_super: AtomicU8::new((VFS_PSEUDO_FS_IDX + 1) as u8),
289+
next_super: AtomicU8::new(VFS_PSEUDO_FS_IDX + 1),
290290
mountpoints: ArcSwap::new(Arc::new(HashMap::new())),
291291
superblocks: ArcSwap::new(Arc::new(vec![None; MAX_VFS_INDEX])),
292292
root: PseudoFs::new(),

src/common/file_buf.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ impl<'a> FileVolatileSlice<'a> {
168168

169169
/// Return a subslice of this [FileVolatileSlice] starting at `offset`.
170170
pub fn offset(&self, count: usize) -> Result<Self, Error> {
171-
let new_addr = (self.addr as usize)
172-
.checked_add(count)
173-
.ok_or(Error::Overflow {
174-
base: self.addr as usize,
175-
offset: count,
176-
})?;
171+
let new_addr = self.addr.checked_add(count).ok_or(Error::Overflow {
172+
base: self.addr,
173+
offset: count,
174+
})?;
177175
let new_size = self
178176
.size
179177
.checked_sub(count)

src/passthrough/sync_io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
257257
if !no_open {
258258
self.handle_map.get(handle, inode)
259259
} else {
260-
let file = self.open_inode(inode, (flags | libc::O_DIRECTORY) as i32)?;
260+
let file = self.open_inode(inode, flags | libc::O_DIRECTORY)?;
261261
Ok(Arc::new(HandleData::new(inode, file)))
262262
}
263263
}
@@ -272,7 +272,7 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
272272
if !no_open {
273273
self.handle_map.get(handle, inode)
274274
} else {
275-
let file = self.open_inode(inode, flags as i32)?;
275+
let file = self.open_inode(inode, flags)?;
276276
Ok(Arc::new(HandleData::new(inode, file)))
277277
}
278278
}
@@ -617,7 +617,7 @@ impl<S: BitmapSlice + Send + Sync> FileSystem for PassthroughFs<S> {
617617
libc::O_RDONLY
618618
};
619619

620-
let file = self.open_inode(inode, open_flags as i32)?;
620+
let file = self.open_inode(inode, open_flags)?;
621621
(*vu_req).map(foffset, moffset, len, flags, file.as_raw_fd())
622622
}
623623

src/transport/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<S: BitmapSlice> IoBuffers<'_, S> {
127127
// `Reader::new()` and `Writer::new()`).
128128
self.buffers
129129
.iter()
130-
.fold(0usize, |count, buf| count + buf.len() as usize)
130+
.fold(0usize, |count, buf| count + buf.len())
131131
}
132132

133133
fn bytes_consumed(&self) -> usize {
@@ -154,7 +154,7 @@ impl<S: BitmapSlice> IoBuffers<'_, S> {
154154
bufs.push(local_buf);
155155

156156
// Don't need check_sub() as we just made sure rem >= local_buf.len()
157-
rem -= local_buf.len() as usize;
157+
rem -= local_buf.len();
158158
}
159159

160160
bufs
@@ -242,7 +242,7 @@ impl<S: BitmapSlice> IoBuffers<'_, S> {
242242
local_buf.bitmap().mark_dirty(0, local_buf.len());
243243

244244
// Don't need check_sub() as we just made sure rem >= local_buf.len()
245-
rem -= local_buf.len() as usize;
245+
rem -= local_buf.len();
246246
}
247247
}
248248

0 commit comments

Comments
 (0)