From be21fae4909018c2a7dfdc496d70c33a237f6a54 Mon Sep 17 00:00:00 2001 From: "Dongjia \"toka\" Zhang" Date: Thu, 12 Dec 2024 22:02:34 +0100 Subject: [PATCH] Remove useless cfgs (#2764) --- libafl/src/corpus/cached.rs | 1 - libafl/src/corpus/inmemory_ondisk.rs | 7 +++---- libafl/src/corpus/ondisk.rs | 1 - libafl/src/executors/command.rs | 2 +- libafl/src/executors/hooks/timer.rs | 4 ++-- libafl/src/executors/inprocess_fork/mod.rs | 2 +- libafl/src/observers/stdio.rs | 9 +++------ libafl/src/stages/sync.rs | 2 +- 8 files changed, 11 insertions(+), 17 deletions(-) diff --git a/libafl/src/corpus/cached.rs b/libafl/src/corpus/cached.rs index dfa7c15f34..2e21fee65c 100644 --- a/libafl/src/corpus/cached.rs +++ b/libafl/src/corpus/cached.rs @@ -18,7 +18,6 @@ use crate::{ /// A corpus that keeps a maximum number of [`Testcase`]s in memory /// and load them from disk, when they are being used. /// The eviction policy is FIFO. -#[cfg(feature = "std")] #[derive(Default, Serialize, Deserialize, Clone, Debug)] pub struct CachedOnDiskCorpus { inner: InMemoryOnDiskCorpus, diff --git a/libafl/src/corpus/inmemory_ondisk.rs b/libafl/src/corpus/inmemory_ondisk.rs index 58be73441d..e879881098 100644 --- a/libafl/src/corpus/inmemory_ondisk.rs +++ b/libafl/src/corpus/inmemory_ondisk.rs @@ -6,11 +6,11 @@ use alloc::string::String; use core::cell::RefCell; -#[cfg(feature = "std")] -use std::{fs, fs::File, io::Write}; use std::{ - fs::OpenOptions, + fs, + fs::{File, OpenOptions}, io, + io::Write, path::{Path, PathBuf}, }; @@ -50,7 +50,6 @@ fn try_create_new>(path: P) -> Result, io::Error> { /// A corpus able to store [`Testcase`]s to disk, while also keeping all of them in memory. /// /// Metadata is written to a `..metadata` file in the same folder by default. -#[cfg(feature = "std")] #[derive(Default, Serialize, Deserialize, Clone, Debug)] pub struct InMemoryOnDiskCorpus { inner: InMemoryCorpus, diff --git a/libafl/src/corpus/ondisk.rs b/libafl/src/corpus/ondisk.rs index db32fd37d9..5c6569538f 100644 --- a/libafl/src/corpus/ondisk.rs +++ b/libafl/src/corpus/ondisk.rs @@ -22,7 +22,6 @@ use crate::{ }; /// Options for the the format of the on-disk metadata -#[cfg(feature = "std")] #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub enum OnDiskMetadataFormat { /// A binary-encoded postcard diff --git a/libafl/src/executors/command.rs b/libafl/src/executors/command.rs index 8471f91b03..9218dfd18a 100644 --- a/libafl/src/executors/command.rs +++ b/libafl/src/executors/command.rs @@ -862,7 +862,7 @@ pub trait CommandConfigurator: Sized { } /// waitpid wrapper that ignores some signals sent by the ptraced child -#[cfg(all(feature = "std", target_os = "linux"))] +#[cfg(target_os = "linux")] fn waitpid_filtered(pid: Pid, options: Option) -> Result { loop { let wait_status = waitpid(pid, options); diff --git a/libafl/src/executors/hooks/timer.rs b/libafl/src/executors/hooks/timer.rs index 21d5541348..bf0639f389 100644 --- a/libafl/src/executors/hooks/timer.rs +++ b/libafl/src/executors/hooks/timer.rs @@ -58,7 +58,7 @@ pub(crate) struct Itimerval { pub it_value: Timeval, } -#[cfg(all(feature = "std", unix, not(target_os = "linux")))] +#[cfg(all(unix, not(target_os = "linux")))] extern "C" { pub(crate) fn setitimer( which: libc::c_int, @@ -102,7 +102,7 @@ pub struct TimerStruct { pub(crate) tmout_start_time: Duration, } -#[cfg(all(feature = "std", windows))] +#[cfg(windows)] #[allow(non_camel_case_types)] type PTP_TIMER_CALLBACK = unsafe extern "system" fn( param0: PTP_CALLBACK_INSTANCE, diff --git a/libafl/src/executors/inprocess_fork/mod.rs b/libafl/src/executors/inprocess_fork/mod.rs index b3386cc03b..e313405bdc 100644 --- a/libafl/src/executors/inprocess_fork/mod.rs +++ b/libafl/src/executors/inprocess_fork/mod.rs @@ -349,7 +349,7 @@ pub mod child_signal_handlers { } #[cfg(test)] -#[cfg(all(feature = "std", feature = "fork", unix))] +#[cfg(all(feature = "fork", unix))] mod tests { use libafl_bolts::tuples::tuple_list; use serial_test::serial; diff --git a/libafl/src/observers/stdio.rs b/libafl/src/observers/stdio.rs index bab111c9d4..266cb68110 100644 --- a/libafl/src/observers/stdio.rs +++ b/libafl/src/observers/stdio.rs @@ -3,7 +3,7 @@ //! The [`StdOutObserver`] and [`StdErrObserver`] observers look at the stdout of a program //! The executor must explicitly support these observers. #![cfg_attr( - all(feature = "std", unix), + unix, doc = r"For example, they are supported on the [`crate::executors::CommandExecutor`]." )] @@ -19,11 +19,8 @@ use crate::{observers::Observer, Error}; /// Only works for supported executors. /// /// # Example usage -#[cfg_attr(all(feature = "std", target_os = "linux", not(miri)), doc = " ```")] // miri doesn't like the Command crate, linux as a shorthand for the availability of base64 -#[cfg_attr( - not(all(feature = "std", target_os = "linux", not(miri))), - doc = " ```ignore" -)] +#[cfg_attr(all(target_os = "linux", not(miri)), doc = " ```")] // miri doesn't like the Command crate, linux as a shorthand for the availability of base64 +#[cfg_attr(not(all(target_os = "linux", not(miri))), doc = " ```ignore")] /// use std::borrow::Cow; /// /// use libafl::{ diff --git a/libafl/src/stages/sync.rs b/libafl/src/stages/sync.rs index a6cbcd3783..7f51ed6f13 100644 --- a/libafl/src/stages/sync.rs +++ b/libafl/src/stages/sync.rs @@ -282,7 +282,7 @@ where client_config: EventConfig::AlwaysUnique, time: current_time(), forward_id: None, - #[cfg(all(unix, feature = "std", feature = "multi_machine"))] + #[cfg(all(unix, feature = "multi_machine"))] node_id: None, }, )?;