From f2f6669bf0405ca3dca481e55c23149a56b2b4cc Mon Sep 17 00:00:00 2001 From: Gwen Lg Date: Sat, 13 Dec 2025 22:37:15 +0100 Subject: [PATCH] style: clean use for question_mark - remove useless `Ok` enclosing with `?` lint message: enclosing `Ok` and `?` operator are unneeded help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#needless_question_mark - use question mark instead of manual implementation lint message: this `match` expression can be replaced with `?` help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#question_mark --- src/api/admin/key.rs | 2 +- src/api/k2v/batch.rs | 4 ++-- src/api/s3/list.rs | 5 +---- src/db/fjall_adapter.rs | 5 ++--- src/db/sqlite_adapter.rs | 2 +- src/model/s3/block_ref_table.rs | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/api/admin/key.rs b/src/api/admin/key.rs index 095c3777..857adca1 100644 --- a/src/api/admin/key.rs +++ b/src/api/admin/key.rs @@ -91,7 +91,7 @@ impl RequestHandler for GetKeyInfoRequest { } }; - Ok(key_info_results(garage, key, self.show_secret_key).await?) + key_info_results(garage, key, self.show_secret_key).await } } diff --git a/src/api/k2v/batch.rs b/src/api/k2v/batch.rs index 7a03d836..5f38cce1 100644 --- a/src/api/k2v/batch.rs +++ b/src/api/k2v/batch.rs @@ -61,7 +61,7 @@ pub async fn handle_read_batch( resps.push(resp?); } - Ok(json_ok_response(&resps)?) + json_ok_response(&resps) } async fn handle_read_batch_query( @@ -155,7 +155,7 @@ pub async fn handle_delete_batch( resps.push(resp?); } - Ok(json_ok_response(&resps)?) + json_ok_response(&resps) } async fn handle_delete_batch_query( diff --git a/src/api/s3/list.rs b/src/api/s3/list.rs index 3772aad9..cc1d88a4 100644 --- a/src/api/s3/list.rs +++ b/src/api/s3/list.rs @@ -725,10 +725,7 @@ impl Accumulator { let object = objects.peek().expect("This iterator can not be empty as it is checked earlier in the code. This is a logic bug, please report it."); // Check if this is a common prefix (requires a passed delimiter and its value in the key) - let pfx = match common_prefix(object, query) { - Some(p) => p, - None => return None, - }; + let pfx = common_prefix(object, query)?; assert!(pfx.starts_with(&query.prefix)); // Try to register this prefix diff --git a/src/db/fjall_adapter.rs b/src/db/fjall_adapter.rs index d1e4f8ac..1a9919f2 100644 --- a/src/db/fjall_adapter.rs +++ b/src/db/fjall_adapter.rs @@ -105,12 +105,11 @@ impl IDb for FjallDb { } fn list_trees(&self) -> Result> { - Ok(self - .keyspace + self.keyspace .list_partitions() .iter() .map(|n| decode_name(n)) - .collect::>>()?) + .collect::>>() } fn snapshot(&self, base_path: &Path) -> Result<()> { diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index 8cc4e119..80fa00f5 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -23,7 +23,7 @@ pub use rusqlite; pub(crate) fn open_db(path: &PathBuf, opt: &OpenOpt) -> Result { info!("Opening Sqlite database at: {}", path.display()); let manager = r2d2_sqlite::SqliteConnectionManager::file(path); - Ok(SqliteDb::new(manager, opt.fsync)?) + SqliteDb::new(manager, opt.fsync) } // ---- diff --git a/src/model/s3/block_ref_table.rs b/src/model/s3/block_ref_table.rs index 57eb7b16..67db109e 100644 --- a/src/model/s3/block_ref_table.rs +++ b/src/model/s3/block_ref_table.rs @@ -98,7 +98,7 @@ pub fn block_ref_recount_fn( .upgrade() .ok_or_message("cannot upgrade weak ptr to block_ref_table") .map_err(db::TxError::Abort)?; - Ok(calculate_refcount(&table, tx, block)?) + calculate_refcount(&table, tx, block) }) }