From 1291a2b3aa816ef181687436174442fb3e89d31d Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 23 Nov 2020 17:21:57 +0800 Subject: [PATCH] kernel: hosted: fix unused variable warnings These only appear when not printing messages. Signed-off-by: Sean Cross --- kernel/src/arch/hosted.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/src/arch/hosted.rs b/kernel/src/arch/hosted.rs index b34620363..f12efd24d 100644 --- a/kernel/src/arch/hosted.rs +++ b/kernel/src/arch/hosted.rs @@ -68,6 +68,7 @@ fn generate_pid_key() -> [u8; 16] { process_key } +#[allow(dead_code)] pub fn current_pid() -> PID { crate::arch::process::current_pid() } @@ -85,13 +86,14 @@ fn handle_connection( ServerPacketWithData([usize; 9], Vec), } - fn conn_thread(mut conn: TcpStream, sender: Sender, pid: PID) { + fn conn_thread(mut conn: TcpStream, sender: Sender, _pid: PID) { loop { let mut raw_data = [0u8; 9 * std::mem::size_of::()]; - if let Err(e) = conn.read_exact(&mut raw_data) { - println!( + if let Err(_e) = conn.read_exact(&mut raw_data) { + #[cfg(not(test))] + eprintln!( "KERNEL({}): client disconnected: {} -- shutting down virtual process", - pid, e + _pid, _e ); sender.send(ServerMessage::Exit).ok(); return; @@ -159,7 +161,8 @@ fn handle_connection( for msg in receiver { match msg { ServerMessage::Exit => { - println!("KERNEL({}): Received ServerMessage::Exit", pid); + #[cfg(not(test))] + eprintln!("KERNEL({}): Received ServerMessage::Exit", pid); break; } ServerMessage::ServerPacket(pkt) => { @@ -259,6 +262,7 @@ fn handle_connection( } } } + #[cfg(not(test))] eprintln!( "KERNEL({}): Finished the thread so sending TerminateProcess", pid