Simplify map_or_log_err
All (non-test) invocations use the same second argument `Ok` (which
actually acts as a 1-arg closure `|v| Ok(v)`), so no need to have it as
a parameter. The common second argument just maps `Ok(v)` to `Ok(v)`,
which means that `map_err()` can be used instead of `map_or_else()`,
and the same type parameter is used for both input and output.
Test: legacykeystore_test
Test: keystore2_test
Flag: None, pure refactor
Change-Id: I46b6e327d0b546df6be6664781a52bb888c04eca
diff --git a/keystore2/src/operation.rs b/keystore2/src/operation.rs
index 290bc74..94bd7c3 100644
--- a/keystore2/src/operation.rs
+++ b/keystore2/src/operation.rs
@@ -822,24 +822,18 @@
impl IKeystoreOperation for KeystoreOperation {
fn updateAad(&self, aad_input: &[u8]) -> binder::Result<()> {
let _wp = wd::watch("IKeystoreOperation::updateAad");
- map_or_log_err(
- self.with_locked_operation(
- |op| op.update_aad(aad_input).context(ks_err!("KeystoreOperation::updateAad")),
- false,
- ),
- Ok,
- )
+ map_or_log_err(self.with_locked_operation(
+ |op| op.update_aad(aad_input).context(ks_err!("KeystoreOperation::updateAad")),
+ false,
+ ))
}
fn update(&self, input: &[u8]) -> binder::Result<Option<Vec<u8>>> {
let _wp = wd::watch("IKeystoreOperation::update");
- map_or_log_err(
- self.with_locked_operation(
- |op| op.update(input).context(ks_err!("KeystoreOperation::update")),
- false,
- ),
- Ok,
- )
+ map_or_log_err(self.with_locked_operation(
+ |op| op.update(input).context(ks_err!("KeystoreOperation::update")),
+ false,
+ ))
}
fn finish(
&self,
@@ -847,13 +841,10 @@
signature: Option<&[u8]>,
) -> binder::Result<Option<Vec<u8>>> {
let _wp = wd::watch("IKeystoreOperation::finish");
- map_or_log_err(
- self.with_locked_operation(
- |op| op.finish(input, signature).context(ks_err!("KeystoreOperation::finish")),
- true,
- ),
- Ok,
- )
+ map_or_log_err(self.with_locked_operation(
+ |op| op.finish(input, signature).context(ks_err!("KeystoreOperation::finish")),
+ true,
+ ))
}
fn abort(&self) -> binder::Result<()> {
@@ -873,7 +864,6 @@
};
e
},
- Ok,
)
}
}