From a2c7dc84441fdc4f2eff34d39cb5e2110c62c19f Mon Sep 17 00:00:00 2001 From: sat0ken <15720506+sat0ken@users.noreply.github.com> Date: Thu, 3 Oct 2024 00:00:15 +0900 Subject: [PATCH] fir code by cargo clippy Signed-off-by: sat0ken <15720506+sat0ken@users.noreply.github.com> --- experiment/seccomp/src/main.rs | 4 ++-- experiment/seccomp/src/seccomp.rs | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/experiment/seccomp/src/main.rs b/experiment/seccomp/src/main.rs index 15ab5572ed..e884c066d4 100644 --- a/experiment/seccomp/src/main.rs +++ b/experiment/seccomp/src/main.rs @@ -1,5 +1,5 @@ use seccomp::{ - instruction::{self, *}, + instruction::{*}, seccomp::{NotifyFd, Seccomp}, }; @@ -98,7 +98,7 @@ async fn main() -> Result<()> { Rule::new("mkdir".parse()?,0, syscall_args!(), true) ] }; - let mut seccomp = Seccomp {filters: Vec::from(inst_data)}; + let seccomp = Seccomp {filters: Vec::from(inst_data)}; tokio::spawn(async move { tokio::signal::ctrl_c() diff --git a/experiment/seccomp/src/seccomp.rs b/experiment/seccomp/src/seccomp.rs index 603a0d285f..f5a83cf452 100644 --- a/experiment/seccomp/src/seccomp.rs +++ b/experiment/seccomp/src/seccomp.rs @@ -15,7 +15,6 @@ use nix::{ unistd, }; use syscalls::{SyscallArgs}; -use syscalls::Sysno::bpf; use crate::instruction::{*}; use crate::instruction::{Arch, Instruction, SECCOMP_IOC_MAGIC}; @@ -204,13 +203,13 @@ struct Filters { fn get_syscall_number(arc: &Arch, name: &str) -> Option { match arc { - &Arch::X86 => { + Arch::X86 => { match syscalls::x86_64::Sysno::from_str(name) { Ok(syscall) => Some(syscall as u64), Err(_) => None, } }, - &Arch::AArch64 => { + Arch::AArch64 => { match syscalls::aarch64::Sysno::from_str(name) { Ok(syscall) => Some(syscall as u64), Err(_) => None, @@ -235,7 +234,7 @@ impl From for Vec { } bpf_prog.append(&mut vec![Instruction::stmt(BPF_RET | BPF_K, SECCOMP_RET_ALLOW)]); - return bpf_prog; + bpf_prog } } @@ -258,7 +257,7 @@ impl Rule { } pub fn to_instruction(arch: &Arch, action: u32, rule: &Rule) -> Vec { - let mut bpf_prog = gen_validate(&arch); + let mut bpf_prog = gen_validate(arch); bpf_prog.append(&mut vec![Instruction::stmt(BPF_LD | BPF_W | BPF_ABS, 0)]); bpf_prog.append(&mut vec![Instruction::jump(BPF_JMP | BPF_JEQ | BPF_K, 0, 1, get_syscall_number(arch, &rule.syscall).unwrap() as c_uint)]); @@ -272,6 +271,6 @@ impl Rule { } else { bpf_prog.append(&mut vec![Instruction::stmt(BPF_RET | BPF_K, action)]); } - return bpf_prog + bpf_prog } }