From 13df958f4ae200a0bf2d8a9b913bdd8e6adcbc1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 13 Mar 2016 21:06:24 +0100 Subject: [PATCH 1/2] Fixing warnings --- util/src/journaldb/earlymergedb.rs | 16 +++++++++------- util/src/keys/store.rs | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/util/src/journaldb/earlymergedb.rs b/util/src/journaldb/earlymergedb.rs index 7f0f50da2..7cb00b993 100644 --- a/util/src/journaldb/earlymergedb.rs +++ b/util/src/journaldb/earlymergedb.rs @@ -171,7 +171,7 @@ impl EarlyMergeDB { trace!(target: "jdb.fine", "replay_keys: (end) refs={:?}", refs); } - fn kill_keys(deletes: &Vec, refs: &mut HashMap, batch: &DBTransaction, from: RemoveFrom, trace: bool) { + fn kill_keys(deletes: &[H256], refs: &mut HashMap, batch: &DBTransaction, from: RemoveFrom, trace: bool) { // with a kill on {queue_refs: 1, in_archive: true}, we have two options: // - convert to {queue_refs: 1, in_archive: false} (i.e. remove it from the conceptual archive) // - convert to {queue_refs: 0, in_archive: true} (i.e. remove it from the conceptual queue) @@ -340,8 +340,10 @@ impl JournalDB for EarlyMergeDB { } } + + #[cfg_attr(feature="dev", allow(cyclomatic_complexity))] fn commit(&mut self, now: u64, id: &H256, end: Option<(u64, H256)>) -> Result { - // journal format: + // journal format: // [era, 0] => [ id, [insert_0, ...], [remove_0, ...] ] // [era, 1] => [ id, [insert_0, ...], [remove_0, ...] ] // [era, n] => [ ... ] @@ -473,7 +475,7 @@ impl JournalDB for EarlyMergeDB { if trace { trace!(target: "jdb.ops", " Finalising: {:?}", inserts); } - for k in inserts.iter() { + for k in &inserts { match refs.get(k).cloned() { None => { // [in archive] -> SHIFT remove -> SHIFT insert None->Some{queue_refs: 1, in_archive: true} -> TAKE remove Some{queue_refs: 1, in_archive: true}->None -> TAKE insert @@ -489,7 +491,7 @@ impl JournalDB for EarlyMergeDB { Self::set_already_in(&batch, k); refs.insert(k.clone(), RefInfo{ queue_refs: x - 1, in_archive: true }); } - Some( RefInfo{queue_refs: _, in_archive: true} ) => { + Some( RefInfo{in_archive: true, ..} ) => { // Invalid! Reinserted the same key twice. warn!("Key {} inserted twice into same fork.", k); } @@ -936,7 +938,7 @@ mod tests { assert!(jdb.can_reconstruct_refs()); assert!(!jdb.exists(&foo)); } - + #[test] fn reopen_test() { let mut dir = ::std::env::temp_dir(); @@ -971,7 +973,7 @@ mod tests { jdb.commit(7, &b"7".sha3(), Some((3, b"3".sha3()))).unwrap(); assert!(jdb.can_reconstruct_refs()); } - + #[test] fn reopen_remove_three() { init_log(); @@ -1025,7 +1027,7 @@ mod tests { assert!(!jdb.exists(&foo)); } } - + #[test] fn reopen_fork() { let mut dir = ::std::env::temp_dir(); diff --git a/util/src/keys/store.rs b/util/src/keys/store.rs index 610dda9f5..8aba08519 100644 --- a/util/src/keys/store.rs +++ b/util/src/keys/store.rs @@ -363,13 +363,13 @@ impl EncryptedHashMap for SecretStore { } #[cfg(test)] +#[cfg(feature="heavy-tests")] mod vector_tests { use super::{derive_mac,derive_key_iterations}; use common::*; #[test] - #[cfg(feature="heavy-tests")] fn mac_vector() { let password = "testpassword"; let salt = H256::from_str("ae3cd4e7013836a3df6bd7241b12db061dbe2c6785853cce422d148a624ce0bd").unwrap(); From fd834084f9f80c2c447e7424e74dddf9ed7e415d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Sun, 13 Mar 2016 21:39:23 +0100 Subject: [PATCH 2/2] unknonw lint --- util/src/table.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/src/table.rs b/util/src/table.rs index 5ba572289..c3b2006cf 100644 --- a/util/src/table.rs +++ b/util/src/table.rs @@ -40,7 +40,7 @@ impl Default for Table } // There is default but clippy does not detect it? -#[allow(new_without_default)] +#[cfg_attr(feature="dev", allow(new_without_default))] impl Table where Row: Eq + Hash + Clone, Col: Eq + Hash {