Skip to content

Commit

Permalink
Fix remaining lints
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-casperlabs committed May 19, 2020
1 parent 1bdd639 commit aa8b295
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Cli {
let mut cert_path = output.clone();
cert_path.set_extension("crt.pem");

let mut key_path = output.clone();
let mut key_path = output;
key_path.set_extension("key.pem");

let (cert, key) = tls::generate_node_cert()?;
Expand Down
23 changes: 3 additions & 20 deletions src/components/small_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ where
R: reactor::Reactor + 'static,
P: Serialize + DeserializeOwned + Clone + fmt::Debug + Send + 'static,
{
#[allow(clippy::type_complexity)]
pub fn new(
eq: reactor::EventQueueHandle<R, Event<P>>,
cfg: config::SmallNetwork,
Expand Down Expand Up @@ -215,6 +216,7 @@ where
)
}

#[allow(clippy::cognitive_complexity)]
pub fn handle_event(&mut self, ev: Event<P>) -> Multiple<Effect<Event<P>>> {
match ev {
Event::RootConnected { cert, transport } => {
Expand Down Expand Up @@ -324,19 +326,6 @@ where
}
}

// TODO: Move to trait.
/// Queue a payload message to be sent to a specific node.
#[inline]
pub fn send(&self, dest: NodeId, payload: P) {
self.send_message(dest, Message::Payload(payload))
}

/// Queue a broadcast to all connected nodes.
#[inline]
pub fn broadcast(&self, payload: P) {
self.broadcast_message(Message::Payload(payload))
}

/// Queue a message to be sent to all nodes.
fn broadcast_message(&self, msg: Message<P>) {
for node_id in self.outgoing.keys() {
Expand Down Expand Up @@ -445,13 +434,7 @@ where
}

// We can now send a snapshot.
let snapshot = Message::Snapshot(
self.signed_endpoints
.values()
.into_iter()
.cloned()
.collect(),
);
let snapshot = Message::Snapshot(self.signed_endpoints.values().cloned().collect());
self.send_message(node_id, snapshot);

message_sender(receiver, sink).event(move |result| Event::OutgoingFailed {
Expand Down
4 changes: 1 addition & 3 deletions src/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ impl Signature {
// The API of OpenSSL is a bit weird here; there is no constant size for the buffer required
// to create the signatures. Additionally, we need to truncate it to the returned size.
let sig_len = signer.len()?;
let mut sig_buf = Vec::with_capacity(sig_len);
sig_buf.resize(sig_len, 0);
let mut sig_buf = vec![0; sig_len];
let bytes_written = signer.sign_oneshot(&mut sig_buf, data)?;
sig_buf.truncate(bytes_written);

Expand Down Expand Up @@ -672,7 +671,6 @@ fn generate_cert(private_key: &pkey::PKey<pkey::Private>, cn: &str) -> SslResult
mod x509_serde {
use super::validate_cert;
use openssl::x509::X509;
use serde;
use std::str;

/// Serde-compatible serialization for X509 certificates.
Expand Down

0 comments on commit aa8b295

Please sign in to comment.