From e3cc4af55f364808aa083ff4a4b8881f8b374be2 Mon Sep 17 00:00:00 2001 From: Ariel Miculas-Trif Date: Thu, 3 Oct 2024 23:17:22 +0300 Subject: [PATCH] Latest clippy has spoken! 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 --- puzzlefs-lib/src/reader/puzzlefs.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/puzzlefs-lib/src/reader/puzzlefs.rs b/puzzlefs-lib/src/reader/puzzlefs.rs index 68b0fa6..048e8c5 100644 --- a/puzzlefs-lib/src/reader/puzzlefs.rs +++ b/puzzlefs-lib/src/reader/puzzlefs.rs @@ -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;