Skip to content

Commit

Permalink
Latest clippy has spoken!
Browse files Browse the repository at this point in the history
Fix the following error reported by clippy:
```
error: manual arithmetic check found
  --> puzzlefs-lib/src/reader/puzzlefs.rs:45:27
   |
45 |           let addl_offset = if offset > file_offset {
   |  ___________________________^
46 | |             offset - file_offset
47 | |         } else {
48 | |             0
49 | |         };
   | |_________^ help: replace it with: `offset.saturating_sub(file_offset)`
      |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implicit_saturating_sub
   = note: `-D clippy::implicit-saturating-sub` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]`
```

Signed-off-by: Ariel Miculas-Trif <[email protected]>
  • Loading branch information
ariel-miculas committed Oct 3, 2024
1 parent 672bb0f commit e3cc4af
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions puzzlefs-lib/src/reader/puzzlefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ pub(crate) fn file_read(
continue;
}

let addl_offset = if offset > file_offset {
offset - file_offset
} else {
0
};
let addl_offset = offset.saturating_sub(file_offset);

// ok, need to read this chunk; how much?
let left_in_buf = data.len() - buf_offset;
Expand Down

0 comments on commit e3cc4af

Please sign in to comment.