Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #670 from ethcore/updating_clippy
Browse files Browse the repository at this point in the history
Updating clippy & fixing warnings.
  • Loading branch information
NikVolf committed Mar 11, 2016
2 parents e6aba74 + f724cab commit 0c9c97f
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 44 deletions.
30 changes: 12 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
fdlimit = { path = "util/fdlimit" }
daemonize = "0.2"
number_prefix = "0.2"
clippy = { version = "0.0.44", optional = true }
clippy = { version = "0.0.49", optional = true }
ethcore = { path = "ethcore" }
ethcore-util = { path = "util" }
ethsync = { path = "sync" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ethcore-util = { path = "../util" }
evmjit = { path = "../evmjit", optional = true }
ethash = { path = "../ethash" }
num_cpus = "0.2"
clippy = { version = "0.0.44", optional = true }
clippy = { version = "0.0.49", optional = true }
crossbeam = "0.1.5"
lazy_static = "0.1"
ethcore-devtools = { path = "../devtools" }
Expand Down
14 changes: 10 additions & 4 deletions ethcore/src/extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ pub enum ExtrasIndex {
BlocksBlooms = 4,
/// Block receipts index
BlockReceipts = 5,
}
}

/// trait used to write Extras data to db
pub trait ExtrasWritable {
/// Write extra data to db
fn put_extras<K, T>(&self, hash: &K, value: &T) where
T: ExtrasIndexable + Encodable,
T: ExtrasIndexable + Encodable,
K: ExtrasSliceConvertable;
}

Expand All @@ -60,9 +60,9 @@ pub trait ExtrasReadable {

impl ExtrasWritable for DBTransaction {
fn put_extras<K, T>(&self, hash: &K, value: &T) where
T: ExtrasIndexable + Encodable,
T: ExtrasIndexable + Encodable,
K: ExtrasSliceConvertable {

self.put(&hash.to_extras_slice(T::extras_index()), &encode(value)).unwrap()
}
}
Expand Down Expand Up @@ -215,6 +215,12 @@ pub struct BlocksBlooms {
pub blooms: [H2048; 16],
}

impl Default for BlocksBlooms {
fn default() -> Self {
BlocksBlooms::new()
}
}

impl BlocksBlooms {
pub fn new() -> Self {
BlocksBlooms { blooms: unsafe { ::std::mem::zeroed() }}
Expand Down
2 changes: 2 additions & 0 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#![cfg_attr(feature="dev", allow(match_bool))]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(feature="dev", allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(feature="dev", allow(if_not_else))]

//! Ethcore library
//!
Expand Down
14 changes: 10 additions & 4 deletions ethcore/src/substate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ pub struct Substate {
pub contracts_created: Vec<Address>
}

impl Default for Substate {
fn default() -> Self {
Substate::new()
}
}

impl Substate {
/// Creates new substate.
pub fn new() -> Self {
Expand Down Expand Up @@ -67,8 +73,8 @@ mod tests {
let mut sub_state = Substate::new();
sub_state.contracts_created.push(address_from_u64(1u64));
sub_state.logs.push(LogEntry {
address: address_from_u64(1u64),
topics: vec![],
address: address_from_u64(1u64),
topics: vec![],
data: vec![]
});
sub_state.sstore_clears_count = x!(5);
Expand All @@ -77,8 +83,8 @@ mod tests {
let mut sub_state_2 = Substate::new();
sub_state_2.contracts_created.push(address_from_u64(2u64));
sub_state_2.logs.push(LogEntry {
address: address_from_u64(1u64),
topics: vec![],
address: address_from_u64(1u64),
topics: vec![],
data: vec![]
});
sub_state_2.sstore_clears_count = x!(7);
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" }
ethash = { path = "../ethash" }
ethsync = { path = "../sync" }
clippy = { version = "0.0.44", optional = true }
clippy = { version = "0.0.49", optional = true }
rustc-serialize = "0.3"
transient-hashmap = "0.1"
serde_macros = { version = "0.7.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies]
ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" }
clippy = { version = "0.0.44", optional = true }
clippy = { version = "0.0.49", optional = true }
log = "0.3"
env_logger = "0.3"
time = "0.1.34"
Expand Down
4 changes: 3 additions & 1 deletion sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
#![warn(missing_docs)]
#![cfg_attr(feature="dev", feature(plugin))]
#![cfg_attr(feature="dev", plugin(clippy))]

// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(feature="dev", allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(feature="dev", allow(if_not_else))]

//! Blockchain sync module
//! Implements ethereum protocol version 63 as specified here:
Expand Down Expand Up @@ -173,6 +174,7 @@ impl NetworkProtocolHandler<SyncMessage> for EthSync {
self.sync.write().unwrap().maintain_sync(&mut NetSyncIo::new(io, self.chain.deref()));
}

#[allow(single_match)]
fn message(&self, io: &NetworkContext<SyncMessage>, message: &SyncMessage) {
match *message {
SyncMessage::NewChainBlocks { ref good, ref bad, ref retracted } => {
Expand Down
8 changes: 8 additions & 0 deletions sync/src/transaction_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
//! - When it's removed from `current` - all transactions from this sender (`current` & `future`) are recalculated.
//!

use std::default::Default;
use std::cmp::{Ordering};
use std::collections::{HashMap, BTreeSet};
use util::numbers::{Uint, U256};
Expand All @@ -102,6 +103,7 @@ struct TransactionOrder {
hash: H256,
}


impl TransactionOrder {
fn for_transaction(tx: &VerifiedTransaction, base_nonce: U256) -> Self {
TransactionOrder {
Expand Down Expand Up @@ -253,6 +255,12 @@ pub struct TransactionQueue {
last_nonces: HashMap<Address, U256>,
}

impl Default for TransactionQueue {
fn default() -> Self {
TransactionQueue::new()
}
}

impl TransactionQueue {
/// Creates new instance of this Queue
pub fn new() -> Self {
Expand Down
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ crossbeam = "0.2"
slab = "0.1"
sha3 = { path = "sha3" }
serde = "0.7.0"
clippy = { version = "0.0.44", optional = true }
clippy = { version = "0.0.49", optional = true }
json-tests = { path = "json-tests" }
rustc_version = "0.1.0"
igd = "0.4.2"
Expand Down
1 change: 0 additions & 1 deletion util/bigint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ rustc-serialize = "0.3"
arrayvec = "0.3"
rand = "0.3.12"
serde = "0.7.0"
clippy = { version = "0.0.44", optional = true }
heapsize = "0.3"

[features]
Expand Down
10 changes: 8 additions & 2 deletions util/src/keys/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ impl AccountService {
}
}

impl Default for SecretStore {
fn default() -> Self {
SecretStore::new()
}
}

impl SecretStore {
/// new instance of Secret Store in default home directory
pub fn new() -> SecretStore {
pub fn new() -> Self {
let mut path = ::std::env::home_dir().expect("Failed to get home dir");
path.push(".parity");
path.push("keys");
Expand All @@ -142,7 +148,7 @@ impl SecretStore {
}

/// new instance of Secret Store in specific directory
pub fn new_in(path: &Path) -> SecretStore {
pub fn new_in(path: &Path) -> Self {
SecretStore {
directory: KeyDirectory::new(path),
unlocks: RwLock::new(HashMap::new()),
Expand Down
7 changes: 7 additions & 0 deletions util/src/kvdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Key-Value store abstraction with RocksDB backend.

use std::default::Default;
use rocksdb::{DB, Writable, WriteBatch, IteratorMode, DBVector, DBIterator,
IndexType, Options, DBCompactionStyle, BlockBasedOptions, Direction};

Expand All @@ -24,6 +25,12 @@ pub struct DBTransaction {
batch: WriteBatch,
}

impl Default for DBTransaction {
fn default() -> Self {
DBTransaction::new()
}
}

impl DBTransaction {
/// Create new transaction.
pub fn new() -> DBTransaction {
Expand Down
2 changes: 2 additions & 0 deletions util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#![cfg_attr(feature="dev", allow(match_same_arms))]
// Keeps consistency (all lines with `.clone()`) and helpful when changing ref to non-ref.
#![cfg_attr(feature="dev", allow(clone_on_copy))]
// In most cases it expresses function flow better
#![cfg_attr(feature="dev", allow(if_not_else))]

//! Ethcore-util library
//!
Expand Down
11 changes: 9 additions & 2 deletions util/src/memorydb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use hashdb::*;
use heapsize::*;
use std::mem;
use std::collections::HashMap;
use std::default::Default;

#[derive(Debug,Clone)]
/// Reference-counted memory-based HashDB implementation.
Expand All @@ -32,7 +33,7 @@ use std::collections::HashMap;
/// with `kill()`, check for existance with `exists()` and lookup a hash to derive
/// the data with `lookup()`. Clear with `clear()` and purge the portions of the data
/// that have no references with `purge()`.
///
///
/// # Example
/// ```rust
/// extern crate ethcore_util;
Expand Down Expand Up @@ -74,6 +75,12 @@ pub struct MemoryDB {
static_null_rlp: (Bytes, i32),
}

impl Default for MemoryDB {
fn default() -> Self {
MemoryDB::new()
}
}

impl MemoryDB {
/// Create a new instance of the memory DB.
pub fn new() -> MemoryDB {
Expand Down Expand Up @@ -133,7 +140,7 @@ impl MemoryDB {

/// Denote than an existing value has the given key. Used when a key gets removed without
/// a prior insert and thus has a negative reference with no value.
///
///
/// May safely be called even if the key's value is known, in which case it will be a no-op.
pub fn denote(&self, key: &H256, value: Bytes) -> &(Bytes, i32) {
if self.raw(key) == None {
Expand Down
Loading

0 comments on commit 0c9c97f

Please sign in to comment.