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

Commit

Permalink
Removes redundant parentheses, whitelists them in generated code (#7721)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x7CFE authored and 5chdn committed Jan 31, 2018
1 parent dae99cc commit a412f7c
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/key_server_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Secret store Key Server set contract.

Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/peer_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Peer set contract.

Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Registrar contract: maps names to addresses and data.
// TODO: testing.
Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/secretstore_acl_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Secret store ACL storage contract.
// TODO: testing.
Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/secretstore_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Secret store service contract.

Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/service_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Service transaction contract.
// TODO: testing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Test validator set contract.

Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/tx_acl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Transact permissions contract.

Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/src/validator_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

#![allow(unused_mut, unused_variables, unused_imports)]
#![allow(unused_mut, unused_variables, unused_imports, unused_parens)]

//! Validator set contract.
// TODO: testing.
Expand Down
4 changes: 2 additions & 2 deletions ethcrypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub mod ecies {
hasher.result(&mut mkey);
let ekey = &key[0..16];

let mut msg = vec![0u8; (1 + 64 + 16 + plain.len() + 32)];
let mut msg = vec![0u8; 1 + 64 + 16 + plain.len() + 32];
msg[0] = 0x04u8;
{
let msgd = &mut msg[1..];
Expand Down Expand Up @@ -262,7 +262,7 @@ pub mod ecies {
hasher.result(&mut mkey);
let ekey = &key[0..16];

let mut msgd = vec![0u8; (64 + plain.len())];
let mut msgd = vec![0u8; 64 + plain.len()];
{
r.public().copy_to(&mut msgd[0..64]);
let iv = H128::from_slice(&z.keccak256()[0..16]);
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/v1/impls/signing_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl<D: Dispatcher + 'static> ParitySigning for SigningUnsafeClient<D> {

fn post_transaction(&self, _: Metadata, _: RpcTransactionRequest) -> BoxFuture<RpcEither<RpcU256, RpcConfirmationResponse>> {
// We don't support this in non-signer mode.
Box::new(future::err((errors::signer_disabled())))
Box::new(future::err(errors::signer_disabled()))
}

fn check_request(&self, _: RpcU256) -> Result<Option<RpcConfirmationResponse>> {
Expand Down
22 changes: 11 additions & 11 deletions updater/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_bool().ok_or("Invalid type returned")?; r })
}

/// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"}],"name":"rejectTransaction","outputs":[],"payable":false,"type":"function"}`
Expand Down Expand Up @@ -186,7 +186,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) })
}

/// Auto-generated from: `{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"proxy","outputs":[{"name":"requiredCount","type":"uint256"},{"name":"to","type":"address"},{"name":"data","type":"bytes"},{"name":"value","type":"uint256"},{"name":"gas","type":"uint256"}],"payable":false,"type":"function"}`
Expand Down Expand Up @@ -222,7 +222,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) })
}

/// Auto-generated from: `{"constant":false,"inputs":[{"name":"_txid","type":"bytes32"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"},{"name":"_value","type":"uint256"},{"name":"_gas","type":"uint256"}],"name":"proposeTransaction","outputs":[{"name":"txSuccess","type":"uint256"}],"payable":false,"type":"function"}`
Expand All @@ -234,7 +234,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()) })
}

/// Auto-generated from: `{"constant":true,"inputs":[],"name":"grandOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"}`
Expand All @@ -246,7 +246,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; ethereum_types::Address::from(r) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_address().ok_or("Invalid type returned")?; ethereum_types::Address::from(r) })
}

/// Auto-generated from: `{"constant":false,"inputs":[{"name":"_release","type":"bytes32"},{"name":"_forkBlock","type":"uint32"},{"name":"_track","type":"uint8"},{"name":"_semver","type":"uint24"},{"name":"_critical","type":"bool"}],"name":"addRelease","outputs":[],"payable":false,"type":"function"}`
Expand Down Expand Up @@ -282,7 +282,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 })
}

/// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"}],"name":"track","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"}`
Expand All @@ -294,7 +294,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u8 }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u8 })
}

/// Auto-generated from: `{"constant":false,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_r","type":"bool"}],"name":"setClientRequired","outputs":[],"payable":false,"type":"function"}`
Expand All @@ -316,7 +316,7 @@ impl Operations {
let data = call.encode_input(&[]).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 })
}

/// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_track","type":"uint8"}],"name":"latestInTrack","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}`
Expand All @@ -328,7 +328,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) })
}

/// Auto-generated from: `{"constant":true,"inputs":[{"name":"_client","type":"bytes32"},{"name":"_release","type":"bytes32"},{"name":"_platform","type":"bytes32"}],"name":"checksum","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"}`
Expand All @@ -340,7 +340,7 @@ impl Operations {
).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_fixed_bytes().ok_or("Invalid type returned")?; ethereum_types::H256::from_slice(r.as_ref()) })
}

/// Auto-generated from: `{"constant":true,"inputs":[],"name":"proposedFork","outputs":[{"name":"","type":"uint32"}],"payable":false,"type":"function"}`
Expand All @@ -350,6 +350,6 @@ impl Operations {
let data = call.encode_input(&[]).map_err(Self::as_string)?;
let output = call.decode_output(&(self.do_call)(self.address.clone(), data)?).map_err(Self::as_string)?;
let mut result = output.into_iter().rev().collect::<Vec<_>>();
Ok(({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 }))
Ok({ let r = result.pop().ok_or("Invalid return arity")?; let r = r.to_uint().ok_or("Invalid type returned")?; ethereum_types::U256::from(r.as_ref()).as_u64() as u32 })
}
}
2 changes: 1 addition & 1 deletion util/kvdb-rocksdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Database {
write_opts: write_opts,
overlay: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()),
flushing: RwLock::new((0..(num_cols + 1)).map(|_| HashMap::new()).collect()),
flushing_lock: Mutex::new((false)),
flushing_lock: Mutex::new(false),
path: path.to_owned(),
read_opts: read_opts,
block_opts: block_opts,
Expand Down
2 changes: 1 addition & 1 deletion util/network/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ impl EncryptedConnection {
let padding = (16 - (payload.len() % 16)) % 16;
header.resize(16, 0u8);

let mut packet = vec![0u8; (32 + payload.len() + padding + 16)];
let mut packet = vec![0u8; 32 + payload.len() + padding + 16];
self.encoder.encrypt(&mut RefReadBuffer::new(&header), &mut RefWriteBuffer::new(&mut packet), false).expect("Invalid length or padding");
EncryptedConnection::update_mac(&mut self.egress_mac, &mut self.mac_encoder, &packet[0..16]);
self.egress_mac.clone().finalize(&mut packet[16..32]);
Expand Down
2 changes: 1 addition & 1 deletion util/rlp/src/untrusted_rlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ impl<'a, 'view> UntrustedRlp<'a> where 'a: 'view {
let mut result = bytes;
for _ in 0..items {
let i = BasicDecoder::payload_info(result)?;
result = UntrustedRlp::consume(result, (i.header_len + i.value_len))?;
result = UntrustedRlp::consume(result, i.header_len + i.value_len)?;
}
Ok(result)
}
Expand Down

0 comments on commit a412f7c

Please sign in to comment.