mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 06:52:13 +00:00
rust-agent: Remove or rename unused variables
Remove variables that are simply not used. Rename as _ variables where only initialization matters. This addresses the following warnings: warning: unused variable: `writer` --> src/main.rs:130:9 | 130 | let writer = unsafe { File::from_raw_fd(wfd) }; | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_writer` | = note: `#[warn(unused_variables)]` on by default warning: unused variable: `ctx` --> src/rpc.rs:782:9 | 782 | ctx: &ttrpc::TtrpcContext, | ^^^ help: if this is intentional, prefix it with an underscore: `_ctx` warning: unused variable: `ctx` --> src/rpc.rs:808:9 | 808 | ctx: &ttrpc::TtrpcContext, | ^^^ help: if this is intentional, prefix it with an underscore: `_ctx` warning: unused variable: `dns_list` --> src/rpc.rs:1152:16 | 1152 | Ok(dns_list) => { | ^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_dns_list` warning: value assigned to `child_stdin` is never read --> rustjail/src/container.rs:807:13 | 807 | let mut child_stdin = std::process::Stdio::null(); | ^^^^^^^^^^^^^^^ | = note: `#[warn(unused_assignments)]` on by default = help: maybe it is overwritten before being read? warning: value assigned to `child_stdout` is never read --> rustjail/src/container.rs:808:13 | 808 | let mut child_stdout = std::process::Stdio::null(); | ^^^^^^^^^^^^^^^^ | = help: maybe it is overwritten before being read? warning: value assigned to `child_stderr` is never read --> rustjail/src/container.rs:809:13 | 809 | let mut child_stderr = std::process::Stdio::null(); | ^^^^^^^^^^^^^^^^ | = help: maybe it is overwritten before being read? warning: value assigned to `stdin` is never read --> rustjail/src/container.rs:810:13 | 810 | let mut stdin = -1; | ^^^^^^^^^ | = help: maybe it is overwritten before being read? warning: value assigned to `stdout` is never read --> rustjail/src/container.rs:811:13 | 811 | let mut stdout = -1; | ^^^^^^^^^^ | = help: maybe it is overwritten before being read? warning: value assigned to `stderr` is never read --> rustjail/src/container.rs:812:13 | 812 | let mut stderr = -1; | ^^^^^^^^^^ | = help: maybe it is overwritten before being read? Fixes: #750 Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
parent
27efe291c0
commit
5a1d331135
@ -799,26 +799,23 @@ impl BaseContainer for LinuxContainer {
|
||||
unistd::close(pwfd);
|
||||
});
|
||||
|
||||
let mut child_stdin = std::process::Stdio::null();
|
||||
let mut child_stdout = std::process::Stdio::null();
|
||||
let mut child_stderr = std::process::Stdio::null();
|
||||
let mut stdin = -1;
|
||||
let mut stdout = -1;
|
||||
let mut stderr = -1;
|
||||
let mut child_stdin: std::process::Stdio;
|
||||
let mut child_stdout: std::process::Stdio;
|
||||
let mut child_stderr: std::process::Stdio;
|
||||
|
||||
if tty {
|
||||
let pseduo = pty::openpty(None, None)?;
|
||||
p.term_master = Some(pseduo.master);
|
||||
fcntl::fcntl(pseduo.master, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
|
||||
fcntl::fcntl(pseduo.slave, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
|
||||
let pseudo = pty::openpty(None, None)?;
|
||||
p.term_master = Some(pseudo.master);
|
||||
fcntl::fcntl(pseudo.master, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
|
||||
fcntl::fcntl(pseudo.slave, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC));
|
||||
|
||||
child_stdin = unsafe { std::process::Stdio::from_raw_fd(pseduo.slave) };
|
||||
child_stdout = unsafe { std::process::Stdio::from_raw_fd(pseduo.slave) };
|
||||
child_stderr = unsafe { std::process::Stdio::from_raw_fd(pseduo.slave) };
|
||||
child_stdin = unsafe { std::process::Stdio::from_raw_fd(pseudo.slave) };
|
||||
child_stdout = unsafe { std::process::Stdio::from_raw_fd(pseudo.slave) };
|
||||
child_stderr = unsafe { std::process::Stdio::from_raw_fd(pseudo.slave) };
|
||||
} else {
|
||||
stdin = p.stdin.unwrap();
|
||||
stdout = p.stdout.unwrap();
|
||||
stderr = p.stderr.unwrap();
|
||||
let stdin = p.stdin.unwrap();
|
||||
let stdout = p.stdout.unwrap();
|
||||
let stderr = p.stderr.unwrap();
|
||||
child_stdin = unsafe { std::process::Stdio::from_raw_fd(stdin) };
|
||||
child_stdout = unsafe { std::process::Stdio::from_raw_fd(stdout) };
|
||||
child_stderr = unsafe { std::process::Stdio::from_raw_fd(stderr) };
|
||||
|
@ -111,6 +111,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[allow(unused_variables)]
|
||||
fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P4: ?Sized + NixPath>(
|
||||
source: Option<&P1>,
|
||||
target: &P2,
|
||||
@ -125,6 +126,7 @@ fn mount<P1: ?Sized + NixPath, P2: ?Sized + NixPath, P3: ?Sized + NixPath, P4: ?
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[allow(unused_variables)]
|
||||
fn umount2<P: ?Sized + NixPath>(
|
||||
target: &P,
|
||||
flags: MntFlags,
|
||||
@ -421,6 +423,7 @@ fn mount_cgroups(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn pivot_root<P1: ?Sized + NixPath, P2: ?Sized + NixPath>(
|
||||
new_root: &P1,
|
||||
put_old: &P2,
|
||||
@ -553,6 +556,7 @@ fn parse_mount_table() -> Result<Vec<Info>> {
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[allow(unused_variables)]
|
||||
fn chroot<P: ?Sized + NixPath>(path: &P) -> Result<(), nix::Error> {
|
||||
#[cfg(not(test))]
|
||||
return unistd::chroot(path);
|
||||
@ -1004,8 +1008,8 @@ mod tests {
|
||||
// there is no spec.mounts, but should pass
|
||||
let ret = init_rootfs(stdout_fd, &spec, &cpath, &mounts, true);
|
||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||
let ret = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let ret = fs::create_dir(rootfs.path().join("dev"));
|
||||
let _ = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let _ = fs::create_dir(rootfs.path().join("dev"));
|
||||
|
||||
// Adding bad mount point to spec.mounts
|
||||
spec.mounts.push(oci::Mount {
|
||||
@ -1023,8 +1027,8 @@ mod tests {
|
||||
ret
|
||||
);
|
||||
spec.mounts.pop();
|
||||
let ret = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let ret = fs::create_dir(rootfs.path().join("dev"));
|
||||
let _ = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let _ = fs::create_dir(rootfs.path().join("dev"));
|
||||
|
||||
// mounting a cgroup
|
||||
spec.mounts.push(oci::Mount {
|
||||
@ -1037,8 +1041,8 @@ mod tests {
|
||||
let ret = init_rootfs(stdout_fd, &spec, &cpath, &mounts, true);
|
||||
assert!(ret.is_ok(), "Should pass. Got: {:?}", ret);
|
||||
spec.mounts.pop();
|
||||
let ret = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let ret = fs::create_dir(rootfs.path().join("dev"));
|
||||
let _ = fs::remove_dir_all(rootfs.path().join("dev"));
|
||||
let _ = fs::create_dir(rootfs.path().join("dev"));
|
||||
|
||||
// mounting /dev
|
||||
spec.mounts.push(oci::Mount {
|
||||
|
@ -151,11 +151,11 @@ mod tests {
|
||||
#[test]
|
||||
fn test_create_extended_pipe() {
|
||||
// Test the default
|
||||
let (r, w) = create_extended_pipe(OFlag::O_CLOEXEC, 0).unwrap();
|
||||
let (_r, _w) = create_extended_pipe(OFlag::O_CLOEXEC, 0).unwrap();
|
||||
|
||||
// Test setting to the max size
|
||||
let max_size = get_pipe_max_size();
|
||||
let (r, w) = create_extended_pipe(OFlag::O_CLOEXEC, max_size).unwrap();
|
||||
let (_, w) = create_extended_pipe(OFlag::O_CLOEXEC, max_size).unwrap();
|
||||
let actual_size = get_pipe_size(w);
|
||||
assert_eq!(max_size, actual_size);
|
||||
}
|
||||
|
@ -129,7 +129,6 @@ fn main() -> Result<()> {
|
||||
|
||||
// support vsock log
|
||||
let (rfd, wfd) = unistd::pipe2(OFlag::O_CLOEXEC)?;
|
||||
let writer = unsafe { File::from_raw_fd(wfd) };
|
||||
|
||||
let agentConfig = AGENT_CONFIG.clone();
|
||||
|
||||
|
@ -1088,7 +1088,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_get_cgroup_v2_mounts() {
|
||||
let dir = tempdir().expect("failed to create tmpdir");
|
||||
let _ = tempdir().expect("failed to create tmpdir");
|
||||
let drain = slog::Discard;
|
||||
let logger = slog::Logger::root(drain, o!());
|
||||
let result = get_cgroup_mounts(&logger, "", true);
|
||||
|
@ -790,7 +790,7 @@ impl protocols::agent_ttrpc::AgentService for agentService {
|
||||
|
||||
fn pause_container(
|
||||
&self,
|
||||
ctx: &ttrpc::TtrpcContext,
|
||||
_ctx: &ttrpc::TtrpcContext,
|
||||
req: protocols::agent::PauseContainerRequest,
|
||||
) -> ttrpc::Result<protocols::empty::Empty> {
|
||||
let cid = req.get_container_id();
|
||||
@ -816,7 +816,7 @@ impl protocols::agent_ttrpc::AgentService for agentService {
|
||||
|
||||
fn resume_container(
|
||||
&self,
|
||||
ctx: &ttrpc::TtrpcContext,
|
||||
_ctx: &ttrpc::TtrpcContext,
|
||||
req: protocols::agent::ResumeContainerRequest,
|
||||
) -> ttrpc::Result<protocols::empty::Empty> {
|
||||
let cid = req.get_container_id();
|
||||
@ -1160,7 +1160,7 @@ impl protocols::agent_ttrpc::AgentService for agentService {
|
||||
};
|
||||
|
||||
match setup_guest_dns(sl!(), req.dns.to_vec()) {
|
||||
Ok(dns_list) => {
|
||||
Ok(_) => {
|
||||
let sandbox = self.sandbox.clone();
|
||||
let mut s = sandbox.lock().unwrap();
|
||||
let _ = req
|
||||
|
Loading…
Reference in New Issue
Block a user