Skip to content

Commit

Permalink
Fix cfg clippy for libafl_qemu (#2397)
Browse files Browse the repository at this point in the history
* optional final comma

* fix systemmode
  • Loading branch information
rmalmain authored Jul 15, 2024
1 parent 9d5be4e commit e8de359
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fuzzers/qemu_systemmode/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ macro_rules! assert_unique_feature {
() => {};
($first:tt $(,$rest:tt)*) => {
$(
#[cfg(all(not(any(doc, feature = "clippy")), feature = $first, feature = $rest))]
#[cfg(all(not(doc), feature = $first, feature = $rest))]
compile_error!(concat!("features \"", $first, "\" and \"", $rest, "\" cannot be used together"));
)*
assert_unique_feature!($($rest),*);
Expand Down
2 changes: 1 addition & 1 deletion libafl_concolic/symcc_runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ macro_rules! export_rust_runtime_fn {
// special case for build_integer_from_buffer cuz the next one just doesn't work!!!!!!!
(pub fn build_integer_from_buffer(
buffer: *mut ::std::os::raw::c_void,
num_bits: ::std::os::raw::c_uint,) -> RSymExpr,$c_name:ident; $rt_cb:path) => {
num_bits: ::std::os::raw::c_uint$(,)?) -> RSymExpr,$c_name:ident; $rt_cb:path) => {
#[allow(clippy::missing_safety_doc)]
#[no_mangle]
pub unsafe extern "C" fn _rsym_build_integer_from_buffer(buffer: *mut ::std::os::raw::c_void, num_bits: ::std::os::raw::c_uint) {
Expand Down
5 changes: 4 additions & 1 deletion libafl_qemu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["fork", "build_libgasan", "build_libqasan", "serdeany_autoreg", "injections"]
clippy = [] # special feature for clippy, don't use in normal projects§
document-features = ["dep:document-features"]
paranoid_debug = ["libafl_qemu_sys/paranoid_debug"] # Will perform as many checks as possible. The target will be greatly slowed down.

Expand Down Expand Up @@ -62,6 +61,10 @@ slirp = [ "systemmode", "libafl_qemu_sys/slirp" ] # build qemu with host libslir
# Requires the binary's build.rs to call `build_libafl_qemu`
shared = [ "libafl_qemu_sys/shared" ]

#! ## Internal features, don't use in normal projects
## clippy workaround
clippy = ["libafl_qemu_sys/clippy"]

[dependencies]
libafl = { path = "../libafl", version = "0.13.1", default-features = false, features = ["std", "derive", "regex"] }
libafl_bolts = { path = "../libafl_bolts", version = "0.13.1", default-features = false, features = ["std", "derive"] }
Expand Down
2 changes: 1 addition & 1 deletion libafl_qemu/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ pub unsafe fn inproc_qemu_timeout_handler<'a, E, EM, OF, Z>(
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasSolutions + HasCorpus + HasExecutions,
Z: HasObjective<Objective = OF, State = E::State>,
Z: HasObjective<Objective = OF, State = E::State> + ExecutionProcessor + HasScheduler,
{
if BREAK_ON_TMOUT {
qemu_system_debug_request();
Expand Down
4 changes: 4 additions & 0 deletions libafl_qemu/src/qemu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ create_hook_id!(Block, libafl_qemu_remove_block_hook, true);
create_hook_id!(Read, libafl_qemu_remove_read_hook, true);
create_hook_id!(Write, libafl_qemu_remove_write_hook, true);
create_hook_id!(Cmp, libafl_qemu_remove_cmp_hook, true);

#[cfg(emulation_mode = "usermode")]
create_hook_id!(PreSyscall, libafl_qemu_remove_pre_syscall_hook, false);
#[cfg(emulation_mode = "usermode")]
create_hook_id!(PostSyscall, libafl_qemu_remove_post_syscall_hook, false);
#[cfg(emulation_mode = "usermode")]
create_hook_id!(NewThread, libafl_qemu_remove_new_thread_hook, false);

#[derive(Debug)]
Expand Down

0 comments on commit e8de359

Please sign in to comment.