From e039e4c2bc96c91e81721e152bfd815eb47f1aef Mon Sep 17 00:00:00 2001 From: guochao Date: Thu, 18 Jan 2024 21:26:13 +0800 Subject: [PATCH] fix unused imports --- src/main.rs | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6f6eb57..fe00eb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,28 +1,36 @@ +#[cfg(feature = "tracing-mode")] use nix::{ - libc::{c_long, EPERM, ORIG_RAX}, - sys::stat::Mode, + libc::{c_long, ORIG_RAX}, unistd::{getpid, getppid, Pid}, }; -use std::io::Write; -use std::{ - ffi::{c_void, CString}, - mem::size_of, -}; +#[cfg(feature = "tracing-mode")] +use std::{ffi::c_void, io::Write, mem::size_of}; + +use nix::{libc::EPERM, sys::stat::Mode}; +use std::ffi::CString; use clap::*; use libseccomp::*; -#[derive(clap::Parser, Debug)] +#[cfg(not(feature = "tracing-mode"))] +#[derive(Parser, Debug)] struct Args { - #[cfg(feature = "tracing-mode")] - #[clap(short, long)] - log_failed_to: Option, - #[clap(required = true)] command: Vec, } + +#[cfg(feature = "tracing-mode")] +#[derive(Parser, Debug)] +struct Args { + #[clap(required = true)] + command: Vec, + + #[clap(short, long)] + log_failed_to: Option, +} + fn main() -> anyhow::Result<()> { env_logger::init(); @@ -33,7 +41,10 @@ fn main() -> anyhow::Result<()> { #[cfg(feature = "tracing-mode")] let tracing = args.log_failed_to != None; + #[cfg(feature = "tracing-mode")] let mut default_action = ScmpAction::Errno(EPERM); + #[cfg(not(feature = "tracing-mode"))] + let default_action = ScmpAction::Errno(EPERM); #[cfg(feature = "tracing-mode")] if let Some(log_fail_to) = args.log_failed_to {