summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-28 20:26:04 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:16 +0300
commit3e1cb18dae463a5b72f3a4c9ebcfe9a05c19fee3 (patch)
tree79a34d44526937fbef96d24d0e339164dc633fa5
parent176fe4658b6c03b0dce1f2d2d1431090db31473f (diff)
Avoid casting a usize to isize in the argument to pointer::offset
Arguably this code should be rewritten to avoid needing "unsafe", but this is the minimal change for reassuring clippy. Found by clippy lint ptr_offset_with_cast: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
-rw-r--r--openpgp-ffi/src/parse/stream.rs3
-rw-r--r--openpgp/src/cert/amalgamation.rs7
2 files changed, 7 insertions, 3 deletions
diff --git a/openpgp-ffi/src/parse/stream.rs b/openpgp-ffi/src/parse/stream.rs
index afd32fee..bd3bd2bc 100644
--- a/openpgp-ffi/src/parse/stream.rs
+++ b/openpgp-ffi/src/parse/stream.rs
@@ -510,7 +510,8 @@ impl VerificationHelper for VHelper {
// (i.e., not a Vec<&Cert>).
let mut certs : Vec<openpgp::Cert> = Vec::with_capacity(cert_refs_raw_len);
for i in 0..cert_refs_raw_len {
- let cert_raw = unsafe { *cert_refs_raw.offset(i as isize) };
+ let i = i as isize;
+ let cert_raw = unsafe { *cert_refs_raw.offset(i) };
certs.push(cert_raw.move_from_raw());
}
diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs
index 9e3c31a1..90350d86 100644
--- a/openpgp/src/cert/amalgamation.rs
+++ b/openpgp/src/cert/amalgamation.rs
@@ -1067,6 +1067,7 @@ impl<'a> UserAttributeAmalgamation<'a> {
}
/// Attests to third-party certifications.
+#[allow(clippy::let_and_return)]
fn attest_certifications_common<C, S>(hash: Box<dyn Digest>,
old_attestation: Option<Signature>,
primary_signer: &mut dyn Signer,
@@ -1109,8 +1110,10 @@ where C: IntoIterator<Item = S>,
let creation_time =
time::SystemTime::now() - time::Duration::new(SIG_BACKDATE_BY, 0);
- SignatureBuilder::new(SignatureType::AttestationKey)
- .set_signature_creation_time(creation_time)?
+ let template = SignatureBuilder::new(SignatureType::AttestationKey)
+ .set_signature_creation_time(creation_time)?;
+ template
+
};
let template = template