Skip to content

Commit

Permalink
fix: remove build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptonemo committed May 5, 2021
1 parent b0057e4 commit 0222226
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
3 changes: 2 additions & 1 deletion fil-proofs-param/tests/paramfetch/session.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fs::File;
use std::io::{self, Read};
use std::panic::panic_any;
use std::path::{Path, PathBuf};

use failure::SyncFailure;
Expand Down Expand Up @@ -63,7 +64,7 @@ impl ParamFetchSessionBuilder {
/// Launch paramfetch in an environment configured by the builder.
pub fn build(self) -> ParamFetchSession {
let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms))
.unwrap_or_else(|err| panic!(err));
.unwrap_or_else(|err| panic_any(err));

let cache_dir_path = format!("{:?}", self.cache_dir.path());

Expand Down
5 changes: 3 additions & 2 deletions fil-proofs-param/tests/parampublish/support/session.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fs::{read_dir, File};
use std::io::{self, Read, Write};
use std::panic::panic_any;
use std::path::{Path, PathBuf};

use failure::SyncFailure;
Expand Down Expand Up @@ -116,12 +117,12 @@ impl ParamPublishSessionBuilder {
/// Launch parampublish in an environment configured by the builder.
pub fn build(self) -> (ParamPublishSession, Vec<PathBuf>) {
let mut p = spawn_bash_with_retries(10, Some(self.session_timeout_ms))
.unwrap_or_else(|err| panic!(err));
.unwrap_or_else(|err| panic_any(err));

let cache_dir_path = format!("{:?}", self.cache_dir.path());

let cache_contents: Vec<PathBuf> = read_dir(&self.cache_dir)
.unwrap_or_else(|_| panic!("failed to read cache dir {:?}", self.cache_dir))
.unwrap_or_else(|_| panic_any(format!("failed to read cache dir {:?}", self.cache_dir)))
.map(|x| x.expect("failed to get dir entry"))
.map(|x| x.path())
.collect();
Expand Down
3 changes: 2 additions & 1 deletion filecoin-hashers/src/blake2s.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::{self, Debug, Formatter};
use std::hash::Hasher as StdHasher;
use std::panic::panic_any;

use anyhow::ensure;
use bellperson::{
Expand Down Expand Up @@ -125,7 +126,7 @@ impl Element for Blake2sDomain {
fn from_slice(bytes: &[u8]) -> Self {
match Blake2sDomain::try_from_bytes(bytes) {
Ok(res) => res,
Err(err) => panic!(err),
Err(err) => panic_any(err),
}
}

Expand Down
9 changes: 5 additions & 4 deletions filecoin-hashers/src/poseidon.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::cmp::Ordering;
use std::hash::{Hash as StdHash, Hasher as StdHasher};
use std::mem::size_of;
use std::panic::panic_any;
use std::slice;

use anyhow::ensure;
Expand Down Expand Up @@ -163,7 +164,7 @@ impl Element for PoseidonDomain {
fn from_slice(bytes: &[u8]) -> Self {
match PoseidonDomain::try_from_bytes(bytes) {
Ok(res) => res,
Err(err) => panic!(err),
Err(err) => panic_any(err),
}
}

Expand Down Expand Up @@ -217,7 +218,7 @@ fn shared_hash_frs(preimage: &[<Bls12 as ScalarEngine>::Fr]) -> <Bls12 as Scalar
p.hash()
}

_ => panic!("Unsupported arity for Poseidon hasher: {}", preimage.len()),
_ => panic_any(format!("Unsupported arity for Poseidon hasher: {}", preimage.len())),
}
}

Expand Down Expand Up @@ -364,12 +365,12 @@ impl LightAlgorithm<PoseidonDomain> for PoseidonFunction {
.enumerate()
.map(|(i, x)| {
<Bls12 as ScalarEngine>::Fr::from_repr(x.0)
.unwrap_or_else(|_| panic!("from_repr failure at {}", i))
.unwrap_or_else(|_| panic_any(format!("from_repr failure at {}", i)))
})
.collect::<Vec<_>>(),
)
.into(),
arity => panic!("unsupported arity {}", arity),
arity => panic_any(format!("unsupported arity {}", arity)),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion filecoin-hashers/src/sha256.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fmt::{self, Debug, Formatter};
use std::hash::Hasher as StdHasher;
use std::panic::panic_any;

use anyhow::ensure;
use bellperson::{
Expand Down Expand Up @@ -148,7 +149,7 @@ impl Element for Sha256Domain {
fn from_slice(bytes: &[u8]) -> Self {
match Sha256Domain::try_from_bytes(bytes) {
Ok(res) => res,
Err(err) => panic!(err),
Err(err) => panic_any(err),
}
}

Expand Down
10 changes: 6 additions & 4 deletions filecoin-proofs/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::panic::panic_any;

use bellperson::bls::Fr;
use ff::Field;
use filecoin_proofs::{
Expand Down Expand Up @@ -49,10 +51,10 @@ fn test_verify_seal_fr32_validation() {

assert!(
haystack.contains(needle),
format!("\"{}\" did not contain \"{}\"", haystack, needle)
"\"{}\" did not contain \"{}\"", haystack, needle,
);
} else {
panic!("should have failed comm_r to Fr32 conversion");
panic_any("should have failed comm_r to Fr32 conversion");
}
}

Expand Down Expand Up @@ -85,10 +87,10 @@ fn test_verify_seal_fr32_validation() {

assert!(
haystack.contains(needle),
format!("\"{}\" did not contain \"{}\"", haystack, needle)
"\"{}\" did not contain \"{}\"", haystack, needle,
);
} else {
panic!("should have failed comm_d to Fr32 conversion");
panic_any("should have failed comm_d to Fr32 conversion");
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion fr32/src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ use std::cmp::min;
use std::io::{self, Read};
use std::mem::size_of;

use byte_slice_cast::{AsByteSlice, AsSliceOf};
#[cfg(not(target_arch = "aarch64"))]
use byte_slice_cast::AsSliceOf;

use byte_slice_cast::AsByteSlice;

/// The number of Frs per Block.
const NUM_FRS_PER_BLOCK: usize = 4;
Expand Down
5 changes: 3 additions & 2 deletions storage-proofs-porep/src/stacked/vanilla/proof.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::fs;
use std::marker::PhantomData;
use std::panic::panic_any;
use std::path::{Path, PathBuf};
use std::sync::Mutex;

Expand Down Expand Up @@ -239,7 +240,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
let labeled_node = rcp.c_x.get_node_at_layer(layer)?;
assert!(
proof.verify(&pub_inputs.replica_id, &labeled_node),
format!("Invalid encoding proof generated at layer {}", layer)
"Invalid encoding proof generated at layer {}", layer,
);
trace!("Valid encoding proof generated at layer {}", layer);
}
Expand Down Expand Up @@ -1238,7 +1239,7 @@ impl<'a, Tree: 'static + MerkleTreeTrait, G: 'static + Hasher> StackedDrg<'a, Tr
)?;
tree_c.root()
}
_ => panic!("Unsupported column arity"),
_ => panic_any("Unsupported column arity"),
};
info!("tree_c done");

Expand Down

0 comments on commit 0222226

Please sign in to comment.