Skip to content

Commit 50eb24e

Browse files
doublegateclaude
andcommitted
style: fix clippy warnings and improve code quality
Fix CI failures on Windows/macOS by addressing Rust 2024 edition requirements: - io_uring.rs: Make HashMap import conditional for Linux only (HashMap is only used in Linux-specific IoUringContext struct) - numa.rs: Add explicit unsafe blocks inside unsafe functions (Rust 2024 requires unsafe blocks for unsafe operations even inside unsafe fn, see rust-lang.org/edition-guide/rust-2024) - aead/mod.rs, aead/session.rs: Fix import ordering per rustfmt - integration_tests.rs: Prefix unused variable with underscore All changes address -D warnings failures in CI runs #129-133. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 489ecb3 commit 50eb24e

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

crates/wraith-crypto/src/aead/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ pub mod replay;
3737
pub mod session;
3838

3939
// Re-export all public types for backward compatibility
40-
pub use cipher::{AeadCipher, AeadKey, Nonce, Tag, KEY_SIZE, NONCE_SIZE, TAG_SIZE};
40+
pub use cipher::{AeadCipher, AeadKey, KEY_SIZE, NONCE_SIZE, Nonce, TAG_SIZE, Tag};
4141
pub use replay::ReplayProtection;
4242
pub use session::{BufferPool, SessionCrypto};

crates/wraith-crypto/src/aead/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! Provides bidirectional encrypted communication with automatic nonce
44
//! management, replay protection, and key-committing AEAD.
55
6-
use crate::CryptoError;
76
use super::cipher::{AeadKey, Nonce};
87
use super::replay::ReplayProtection;
8+
use crate::CryptoError;
99
use zeroize::ZeroizeOnDrop;
1010

1111
/// Reusable buffer pool to avoid allocation in hot path.

crates/wraith-transport/src/io_uring.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
//! # }
4646
//! ```
4747
48+
#[cfg(target_os = "linux")]
4849
use std::collections::HashMap;
4950
use std::io;
5051
use thiserror::Error;

crates/wraith-transport/src/numa.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ pub unsafe fn allocate_on_node(size: usize, _node: usize) -> Option<*mut u8> {
156156
use std::alloc::{Layout, alloc};
157157

158158
let layout = Layout::from_size_align(size, std::mem::align_of::<u8>()).ok()?;
159-
let ptr = alloc(layout);
159+
// SAFETY: Layout is valid (created from `from_size_align` which validated alignment).
160+
// Caller is responsible for deallocating with `deallocate_on_node`.
161+
let ptr = unsafe { alloc(layout) };
160162

161163
if ptr.is_null() { None } else { Some(ptr) }
162164
}
@@ -194,8 +196,10 @@ pub unsafe fn deallocate_on_node(ptr: *mut u8, size: usize) {
194196
if !ptr.is_null() {
195197
// SAFETY: Layout matches the allocation from allocate_on_node (non-Linux path).
196198
// Pointer and size must be valid from original allocation (enforced by caller).
197-
let layout = Layout::from_size_align_unchecked(size, std::mem::align_of::<u8>());
198-
dealloc(ptr, layout);
199+
// The alignment is always valid (1 for u8).
200+
let layout = unsafe { Layout::from_size_align_unchecked(size, std::mem::align_of::<u8>()) };
201+
// SAFETY: ptr was allocated with the same layout via allocate_on_node.
202+
unsafe { dealloc(ptr, layout) };
199203
}
200204
}
201205

tests/integration_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ fn test_relay_fallback() {
948948
use wraith_discovery::{ConnectionType, RelayInfo};
949949

950950
// 1. Attempt direct connection (simulated failure)
951-
let direct_connection = ConnectionType::Direct;
951+
let _direct_connection = ConnectionType::Direct;
952952
let direct_available = false; // Simulate NAT/firewall blocking
953953

954954
// 2. Fall back to relay

0 commit comments

Comments
 (0)