Skip to content

Commit ca62026

Browse files
committed
fix: Clean up all compiler warnings
- Add #[allow(dead_code)] annotations to async features - Fix unused imports in tests - Gate async-dependent tests with feature flag - Zero compiler warnings remaining
1 parent 8e32ae2 commit ca62026

File tree

5 files changed

+19
-1
lines changed

5 files changed

+19
-1
lines changed

src/pty/io_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::pty_buffer::PtyBuffer;
1111

1212
/// Buffer size constants for improved performance
1313
pub const DEFAULT_BUFFER_SIZE: usize = 16384; // 16KB for better throughput
14+
#[allow(dead_code)]
1415
pub const SMALL_BUFFER_SIZE: usize = 4096; // 4KB for control messages
1516

1617
/// Handle reading from PTY master and broadcasting to clients

src/pty/io_handler_async.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ use crate::pty::socket_async::DEFAULT_BUFFER_SIZE;
1212
use crate::pty_buffer::PtyBuffer;
1313

1414
/// Handle reading from PTY master and broadcasting to clients (async version)
15+
#[allow(dead_code)]
1516
pub struct AsyncPtyIoHandler {
1617
master_fd: RawFd,
1718
buffer_size: usize,
1819
}
1920

21+
#[allow(dead_code)]
2022
impl AsyncPtyIoHandler {
2123
pub fn new(master_fd: RawFd) -> Self {
2224
Self {
@@ -67,11 +69,13 @@ impl AsyncPtyIoHandler {
6769
}
6870

6971
/// Handle scrollback buffer management with thread-safe async operations
72+
#[allow(dead_code)]
7073
pub struct AsyncScrollbackHandler {
7174
buffer: Arc<RwLock<Vec<u8>>>,
7275
max_size: usize,
7376
}
7477

78+
#[allow(dead_code)]
7579
impl AsyncScrollbackHandler {
7680
pub fn new(max_size: usize) -> Self {
7781
Self {
@@ -104,6 +108,7 @@ impl AsyncScrollbackHandler {
104108
}
105109

106110
/// Async task that reads from socket and writes to stdout
111+
#[allow(dead_code)]
107112
pub async fn socket_to_stdout_task(
108113
mut socket: UnixStream,
109114
running: Arc<AtomicBool>,
@@ -158,6 +163,7 @@ pub async fn socket_to_stdout_task(
158163
}
159164

160165
/// Async task that monitors terminal size changes
166+
#[allow(dead_code)]
161167
pub async fn resize_monitor_task(
162168
mut socket: UnixStream,
163169
running: Arc<AtomicBool>,
@@ -183,6 +189,7 @@ pub async fn resize_monitor_task(
183189
}
184190

185191
/// Helper to send buffered output to a new client (async version)
192+
#[allow(dead_code)]
186193
pub async fn send_buffered_output_async(
187194
stream: &mut UnixStream,
188195
output_buffer: &PtyBuffer,
@@ -226,11 +233,13 @@ pub async fn send_buffered_output_async(
226233
}
227234

228235
/// Session manager using Arc<RwLock> for multi-threaded access
236+
#[allow(dead_code)]
229237
pub struct AsyncSessionManager {
230238
sessions: Arc<RwLock<std::collections::HashMap<String, SessionData>>>,
231239
}
232240

233241
#[derive(Clone)]
242+
#[allow(dead_code)]
234243
pub struct SessionData {
235244
pub id: String,
236245
pub master_fd: RawFd,
@@ -239,6 +248,7 @@ pub struct SessionData {
239248
pub created_at: std::time::SystemTime,
240249
}
241250

251+
#[allow(dead_code)]
242252
impl AsyncSessionManager {
243253
pub fn new() -> Self {
244254
Self {

src/pty/socket_async.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ use crate::error::{NdsError, Result};
77
use crate::session::Session;
88

99
/// Buffer size constants for improved performance
10+
#[allow(dead_code)]
1011
pub const DEFAULT_BUFFER_SIZE: usize = 16384; // 16KB for better throughput
12+
#[allow(dead_code)]
1113
pub const SMALL_BUFFER_SIZE: usize = 4096; // 4KB for control messages
1214

1315
/// Creates a Unix socket listener for a session with secure permissions
16+
#[allow(dead_code)]
1417
pub async fn create_listener_async(session_id: &str) -> Result<(UnixListener, PathBuf)> {
1518
let socket_path = Session::socket_dir()?.join(format!("{}.sock", session_id));
1619

@@ -33,6 +36,7 @@ pub async fn create_listener_async(session_id: &str) -> Result<(UnixListener, Pa
3336
}
3437

3538
/// Send a resize command to the daemon through the socket (async version)
39+
#[allow(dead_code)]
3640
pub async fn send_resize_command_async(
3741
socket: &mut UnixStream,
3842
cols: u16,
@@ -114,6 +118,7 @@ pub fn is_valid_command(cmd: &str) -> bool {
114118
}
115119

116120
/// Get the end index of an NDS command in the data (with bounds checking)
121+
#[allow(dead_code)]
117122
pub fn get_command_end_secure(data: &[u8]) -> Option<usize> {
118123
if data.len() < 8192 && data.starts_with(b"\x1b]nds:") {
119124
if let Ok(cmd_str) = std::str::from_utf8(data) {

src/pty/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ mod tests {
188188
use crate::pty::client::*;
189189
use crate::pty::io_handler::*;
190190
use crate::pty::socket::*;
191-
use crate::pty::terminal::*;
192191

193192
#[test]
194193
fn test_parse_nds_command_empty() {

tests/security_test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn test_socket_permissions() {
2424
}
2525

2626
#[test]
27+
#[cfg(feature = "async")]
2728
fn test_input_sanitization() {
2829
use detached_shell::pty::socket_async::{is_valid_command, sanitize_string_input};
2930

@@ -40,6 +41,7 @@ fn test_input_sanitization() {
4041
}
4142

4243
#[test]
44+
#[cfg(feature = "async")]
4345
fn test_numeric_bounds() {
4446
use detached_shell::pty::socket_async::sanitize_numeric_input;
4547

@@ -50,6 +52,7 @@ fn test_numeric_bounds() {
5052
}
5153

5254
#[test]
55+
#[cfg(feature = "async")]
5356
fn test_command_length_limits() {
5457
use detached_shell::pty::socket_async::parse_nds_command_secure;
5558

0 commit comments

Comments
 (0)