From dda8497d5442f7d2d83f2554acb3686f3ab4167a Mon Sep 17 00:00:00 2001 From: Simon B Date: Thu, 10 Jan 2019 00:01:06 +0100 Subject: [PATCH] clippy says: avoid needless "1 *" clippy says: make operator precedence explicit --- core/src/consensus.rs | 2 +- keychain/src/mnemonic.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/consensus.rs b/core/src/consensus.rs index a6d0ef841..059ffa4fe 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -250,7 +250,7 @@ impl HeaderInfo { /// Move value linearly toward a goal pub fn damp(actual: u64, goal: u64, damp_factor: u64) -> u64 { - (1 * actual + (damp_factor - 1) * goal) / damp_factor + (actual + (damp_factor - 1) * goal) / damp_factor } /// limit value to be within some factor from a goal diff --git a/keychain/src/mnemonic.rs b/keychain/src/mnemonic.rs index b68585049..1dfb66bf4 100644 --- a/keychain/src/mnemonic.rs +++ b/keychain/src/mnemonic.rs @@ -89,7 +89,7 @@ pub fn to_entropy(mnemonic: &str) -> Result, Error> { for index in indexes.iter().rev() { for i in 0..11 { let bit = index & (1 << i) != 0; - entropy[datalen - loc / 8] |= (bit as u8) << loc % 8; + entropy[datalen - loc / 8] |= (bit as u8) << (loc % 8); loc += 1; } } @@ -99,7 +99,7 @@ pub fn to_entropy(mnemonic: &str) -> Result, Error> { sha2sum.input(&entropy.clone()); hash.copy_from_slice(sha2sum.result().as_slice()); - let actual = (hash[0] >> 8 - checksum_bits) & mask; + let actual = (hash[0] >> (8 - checksum_bits)) & mask; if actual != checksum { return Err(Error::BadChecksum(checksum, actual)); @@ -134,13 +134,13 @@ pub fn from_entropy(entropy: &Vec) -> Result { for byte in entropy.iter() { for i in (0..8).rev() { let bit = byte & (1 << i) != 0; - indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11); + indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11)); loc += 1; } } for i in (0..checksum_bits).rev() { let bit = checksum & (1 << i) != 0; - indexes[loc / 11] |= (bit as u16) << 10 - (loc % 11); + indexes[loc / 11] |= (bit as u16) << (10 - (loc % 11)); loc += 1; }