Skip to content

Commit a306512

Browse files
authored
Merge pull request #1337 from jbesraa/2025-01-09-ignore-warnings
Handle `cargo build` warnings
2 parents 4190257 + 4e881e9 commit a306512

File tree

11 files changed

+20
-7
lines changed

11 files changed

+20
-7
lines changed

protocols/v2/binary-sv2/no-serde-sv2/codec/src/codec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ pub trait Fixed {
112112
}
113113

114114
// Not used and will be removed during refactoring
115+
#[allow(dead_code)]
115116
pub trait Variable {
116117
const HEADER_SIZE: usize;
117118
//const ELEMENT_SIZE: usize;

protocols/v2/binary-sv2/no-serde-sv2/codec/src/datatypes/non_copy_data_types/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use alloc::vec::Vec;
4040
mod inner;
4141
mod seq_inner;
4242

43+
#[allow(dead_code)]
4344
trait IntoOwned {
4445
fn into_owned(self) -> Self;
4546
}

protocols/v2/binary-sv2/serde-sv2/src/de.rs

+1
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
453453
}
454454
}
455455

456+
#[allow(dead_code)]
456457
struct Seq<'de, 'a> {
457458
de: &'a mut Deserializer<'de>,
458459
len: usize,

protocols/v2/binary-sv2/serde-sv2/src/primitives/byte_arrays/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pub mod b064k;
55
pub mod bytes;
66

77
pub trait IntoStatic {
8+
#[allow(dead_code)]
89
fn into_static(self) -> Self;
910
}
1011

protocols/v2/noise-sv2/src/cipher_state.rs

+2
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,15 @@ where
9595
res
9696
}
9797

98+
#[allow(dead_code)]
9899
fn into_aesg(mut self) -> Option<Cipher<Aes256Gcm>> {
99100
#[allow(clippy::clone_on_copy)]
100101
let k = self.get_k().clone()?;
101102
let c = Aes256Gcm::from_key(k);
102103
Some(Cipher::from_cipher(c))
103104
}
104105

106+
#[allow(dead_code)]
105107
fn into_chacha(mut self) -> Option<Cipher<ChaCha20Poly1305>> {
106108
#[allow(clippy::clone_on_copy)]
107109
let k = self.get_k().clone()?;

protocols/v2/noise-sv2/src/handshake.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ pub trait HandshakeOp<Cipher: AeadCipher>: CipherState<Cipher> {
101101
// Generates a fresh key pair, consisting of a secret key and a corresponding public key,
102102
// using the [`Secp256k1`] elliptic curve. If the generated public key does not match the
103103
// expected parity, a new key pair is generated to ensure consistency.
104+
#[allow(dead_code)]
104105
#[cfg(feature = "std")]
105106
fn generate_key() -> Keypair {
106107
Self::generate_key_with_rng(&mut rand::thread_rng())
@@ -173,6 +174,7 @@ pub trait HandshakeOp<Cipher: AeadCipher>: CipherState<Cipher> {
173174
(out_1, out_2)
174175
}
175176

177+
#[allow(dead_code)]
176178
fn hkdf_3(
177179
chaining_key: &[u8; 32],
178180
input_key_material: &[u8],
@@ -236,6 +238,7 @@ pub trait HandshakeOp<Cipher: AeadCipher>: CipherState<Cipher> {
236238
Ok(())
237239
}
238240

241+
#[allow(dead_code)]
239242
fn ecdh(private: &[u8], public: &[u8]) -> [u8; 32] {
240243
let private = SecretKey::from_slice(private).expect("Wrong key");
241244
let x_public = XOnlyPublicKey::from_slice(public).expect("Wrong key");
@@ -284,7 +287,7 @@ mod test {
284287
use core::convert::TryInto;
285288
use quickcheck::{Arbitrary, TestResult};
286289
use quickcheck_macros;
287-
use secp256k1::{ecdh::SharedSecret, SecretKey, XOnlyPublicKey};
290+
use secp256k1::SecretKey;
288291

289292
struct TestHandShake {
290293
k: Option<[u8; 32]>,

protocols/v2/noise-sv2/src/signature_message.rs

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ impl SignatureNoiseMessage {
7171
//
7272
// If an authority public key is not provided, the function assumes that the signature
7373
// is already valid without further verification.
74+
#[allow(dead_code)]
7475
#[cfg(feature = "std")]
7576
pub fn verify(self, pk: &XOnlyPublicKey, authority_pk: &Option<XOnlyPublicKey>) -> bool {
7677
let now = std::time::SystemTime::now()
@@ -119,6 +120,7 @@ impl SignatureNoiseMessage {
119120
// Creates a Schnorr signature for the message, combining the version, validity period, and
120121
// the static public key of the server (`static_pk`). The resulting signature is then written
121122
// into the provided message buffer (`msg`).
123+
#[allow(dead_code)]
122124
#[cfg(feature = "std")]
123125
pub fn sign(msg: &mut [u8; 74], static_pk: &XOnlyPublicKey, kp: &Keypair) {
124126
Self::sign_with_rng(msg, static_pk, kp, &mut rand::thread_rng());

protocols/v2/roles-logic-sv2/src/job_dispatcher.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ impl<'a> BlockHeader<'a> {
7474
// helper struct to identify Standard Jobs being managed for downstream
7575
#[derive(Debug)]
7676
struct DownstreamJob {
77+
#[allow(dead_code)]
7778
merkle_root: Vec<u8>,
7879
extended_job_id: u32,
7980
}

protocols/v2/roles-logic-sv2/src/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ pub fn target_from_hash_rate(hash_per_second: f32, share_per_min: f32) -> U256<'
797797
}
798798

799799
/// TODO: Not used, to be removed.
800-
#[cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))]
800+
#[allow(clippy::too_many_arguments)]
801801
pub fn get_target(
802802
nonce: u32,
803803
version: u32,

protocols/v2/sv2-ffi/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ pub extern "C" fn new_encoder() -> *mut EncoderWrapper {
388388
pub extern "C" fn flush_encoder(encoder: *mut EncoderWrapper) {
389389
let mut encoder = unsafe { Box::from_raw(encoder) };
390390
encoder.free = true;
391-
Box::into_raw(encoder);
391+
let _ = Box::into_raw(encoder);
392392
}
393393

394394
fn encode_(
@@ -431,7 +431,7 @@ pub unsafe extern "C" fn encode(
431431
if encoder.free {
432432
let result = encode_(message, &mut encoder);
433433
encoder.free = false;
434-
Box::into_raw(encoder);
434+
let _ = Box::into_raw(encoder);
435435
result.into()
436436
} else {
437437
CResult::Err(Sv2Error::EncoderBusy)
@@ -453,7 +453,7 @@ pub extern "C" fn get_writable(decoder: *mut DecoderWrapper) -> CVec {
453453
let mut decoder = unsafe { Box::from_raw(decoder) };
454454
let writable = decoder.0.writable();
455455
let res = CVec::as_shared_buffer(writable);
456-
Box::into_raw(decoder);
456+
let _ = Box::into_raw(decoder);
457457
res
458458
}
459459

@@ -472,15 +472,15 @@ pub extern "C" fn next_frame(decoder: *mut DecoderWrapper) -> CResult<CSv2Messag
472472
let len = payload.len();
473473
let ptr = payload.as_mut_ptr();
474474
let payload = unsafe { std::slice::from_raw_parts_mut(ptr, len) };
475-
Box::into_raw(decoder);
475+
let _ = Box::into_raw(decoder);
476476
(msg_type, payload)
477477
.try_into()
478478
.map(|x: Sv2Message| x.into())
479479
.map_err(|_| Sv2Error::Unknown)
480480
.into()
481481
}
482482
Err(_) => {
483-
Box::into_raw(decoder);
483+
let _ = Box::into_raw(decoder);
484484
CResult::Err(Sv2Error::MissingBytes)
485485
}
486486
}

roles/roles-utils/rpc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize};
44
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
55
pub struct Hash([u8; 32]);
66

7+
#[allow(dead_code)]
78
#[derive(Clone, Deserialize)]
89
pub struct Amount(f64);
910

0 commit comments

Comments
 (0)