Skip to content

Commit 7aa72b4

Browse files
bergwolfimeoer
authored andcommitted
ci: refactor conditional logic in sync_io.rs
Replace nested if-else with match expression for improved readability when handling file stat operations based on no_open flag and handle availability. The change simplifies the control flow by using pattern matching to handle the four possible combinations of no_open state and handle presence in a single expression. Signed-off-by: Peng Tao <bergwolf@hyper.sh>
1 parent 95c4fff commit 7aa72b4

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/passthrough/sync_io.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ impl<S: BitmapSlice + Send + Sync> PassthroughFs<S> {
237237

238238
// kernel sends 0 as handle in case of no_open, and it depends on fuse server to handle
239239
// this case correctly.
240-
let st = if !self.no_open.load(Ordering::Relaxed) && handle.is_some() {
241-
// Safe as we just checked handle
242-
let hd = self.handle_map.get(handle.unwrap(), inode)?;
243-
stat_fd(hd.get_file(), None)
244-
} else {
245-
data.handle.stat()
240+
let st = match (!self.no_open.load(Ordering::Relaxed), handle) {
241+
(true, Some(h)) => {
242+
let hd = self.handle_map.get(h, inode)?;
243+
stat_fd(hd.get_file(), None)
244+
}
245+
_ => data.handle.stat(),
246246
};
247247

248248
let st = st.map_err(|e| {

0 commit comments

Comments
 (0)