agent: fix dead_code lint

Fixes: #1359

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2021-02-04 21:11:50 +08:00
parent 05da23acb7
commit e28bf7a59d
6 changed files with 5 additions and 43 deletions

View File

@ -26,10 +26,6 @@ const VSOCK_PORT: u16 = 1024;
const SERVER_ADDR_ENV_VAR: &str = "KATA_AGENT_SERVER_ADDR";
const LOG_LEVEL_ENV_VAR: &str = "KATA_AGENT_LOG_LEVEL";
// FIXME: unused
const TRACE_MODE_FLAG: &str = "agent.trace";
const USE_VSOCK_FLAG: &str = "agent.use_vsock";
#[derive(Debug)]
pub struct agentConfig {
pub debug_console: bool,

View File

@ -6,7 +6,6 @@
#![allow(non_camel_case_types)]
#![allow(unused_parens)]
#![allow(unused_unsafe)]
#![allow(dead_code)]
#[macro_use]
extern crate lazy_static;
extern crate oci;

View File

@ -68,6 +68,7 @@ impl Namespace {
self
}
#[allow(dead_code)]
pub fn set_root_dir(mut self, dir: &str) -> Self {
self.persistent_ns_dir = dir.to_string();
self

View File

@ -40,6 +40,7 @@ pub enum AddressFilter {
/// Return addresses that belong to the given interface.
LinkIndex(u32),
/// Get addresses with the given prefix.
#[allow(dead_code)]
IpAddress(IpAddr),
}
@ -215,17 +216,6 @@ impl Handle {
Ok(())
}
pub async fn delete_links<I>(&mut self, list: I) -> Result<()>
where
I: IntoIterator<Item = u32>,
{
for index in list.into_iter() {
self.handle.link().del(index).execute().await?;
}
Ok(())
}
async fn query_routes(
&self,
ip_version: Option<IpVersion>,
@ -742,6 +732,7 @@ impl Address {
self.0.header.family == packet::constants::AF_INET6 as u8
}
#[allow(dead_code)]
fn prefix(&self) -> u8 {
self.0.header.prefix_len
}

View File

@ -150,14 +150,6 @@ impl Sandbox {
Ok(())
}
pub fn is_running(&self) -> bool {
self.running
}
pub fn set_hostname(&mut self, hostname: String) {
self.hostname = hostname;
}
pub async fn setup_shared_namespaces(&mut self) -> Result<bool> {
// Set up shared IPC namespace
self.shared_ipcns = Namespace::new(&self.logger)
@ -732,25 +724,6 @@ mod tests {
assert!(s.hooks.as_ref().unwrap().poststop.is_empty());
}
#[tokio::test]
async fn test_sandbox_is_running() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
s.running = true;
assert!(s.is_running());
s.running = false;
assert!(!s.is_running());
}
#[tokio::test]
async fn test_sandbox_set_hostname() {
let logger = slog::Logger::root(slog::Discard, o!());
let mut s = Sandbox::new(&logger).unwrap();
let hostname = "abc123";
s.set_hostname(hostname.to_string());
assert_eq!(s.hostname, hostname);
}
#[tokio::test]
async fn test_sandbox_set_destroy() {
let logger = slog::Logger::root(slog::Discard, o!());

View File

@ -7,6 +7,8 @@
// WARNING: This file is auto-generated - DO NOT EDIT!
//
#![allow(dead_code)]
pub const AGENT_VERSION: &str = "@AGENT_VERSION@";
pub const API_VERSION: &str = "@API_VERSION@";
pub const VERSION_COMMIT: &str = "@VERSION_COMMIT@";