Skip to content

Commit

Permalink
bolts: haiku, addressing clippy warnings (#1647)
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored Nov 4, 2023
1 parent 56b37bb commit bae24d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 2 additions & 0 deletions libafl_bolts/src/core_affinity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,12 +350,14 @@ mod linux {
// FIXME: no sense of cpu granularity (yet ?)

#[cfg(target_os = "haiku")]
#[allow(clippy::unnecessary_wraps)]
#[inline]
fn get_core_ids_helper() -> Result<Vec<CoreId>, Error> {
Ok(Vec::new())
}

#[cfg(target_os = "haiku")]
#[allow(clippy::unnecessary_wraps)]
#[inline]
fn set_for_current_helper(_core_id: CoreId) -> Result<(), Error> {
Ok(())
Expand Down
9 changes: 5 additions & 4 deletions libafl_bolts/src/minibsod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ fn write_crash<W: Write>(
_ucontext: &ucontext_t,
) -> Result<(), std::io::Error> {
// TODO add fault addr for other platforms.
writeln!(writer, "Received signal {}", signal,)?;
writeln!(writer, "Received signal {signal}")?;

Ok(())
}
Expand Down Expand Up @@ -848,15 +848,16 @@ fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Er

#[cfg(target_os = "haiku")]
fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Error> {
let mut info: libc::image_info = unsafe { std::mem::zeroed() };
let p = std::mem::MaybeUninit::<libc::image_info>::uninit();
let mut info = unsafe { p.assume_init() };
let mut c: i32 = 0;

loop {
if unsafe { libc::get_next_image_info(0, &mut c, &mut info) } == libc::B_OK {
let i = format!(
"{}-{} {:?}\n",
info.text as u64,
info.text as u64 + info.text_size as u64,
info.text as i64,
info.text as i64 + i64::from(info.text_size),
info.name
);
writer.write_all(&i.into_bytes())?;
Expand Down
14 changes: 7 additions & 7 deletions libafl_bolts/src/shmem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use core::fmt::Display;
use core::{cell::RefCell, fmt, mem::ManuallyDrop};
#[cfg(feature = "std")]
use std::env;
#[cfg(all(unix, feature = "std"))]
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
use std::io::Read;
#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(target_os = "haiku")))]
use std::io::Write;

use serde::{Deserialize, Serialize};
Expand All @@ -27,7 +27,7 @@ pub use unix_shmem::{UnixShMem, UnixShMemProvider};
#[cfg(all(windows, feature = "std"))]
pub use win32_shmem::{Win32ShMem, Win32ShMemProvider};

#[cfg(all(unix, feature = "std"))]
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
use crate::os::pipes::Pipe;
#[cfg(all(feature = "std", unix, not(target_os = "haiku")))]
pub use crate::os::unix_shmem_server::{ServedShMemProvider, ShMemService};
Expand Down Expand Up @@ -411,7 +411,7 @@ impl<T: ShMemProvider> Drop for RcShMem<T> {
/// that can use internal mutability.
/// Useful if the `ShMemProvider` needs to keep local state.
#[derive(Debug, Clone)]
#[cfg(all(unix, feature = "std"))]
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
pub struct RcShMemProvider<SP>
where
SP: ShMemProvider,
Expand Down Expand Up @@ -505,7 +505,7 @@ where
}
}

#[cfg(all(unix, feature = "std"))]
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
impl<SP> RcShMemProvider<SP>
where
SP: ShMemProvider,
Expand Down Expand Up @@ -1457,7 +1457,7 @@ pub struct ShMemCursor<T: ShMem> {
pos: usize,
}

#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(target_os = "haiku")))]
impl<T: ShMem> ShMemCursor<T> {
/// Create a new [`ShMemCursor`] around [`ShMem`]
pub fn new(shmem: T) -> Self {
Expand All @@ -1473,7 +1473,7 @@ impl<T: ShMem> ShMemCursor<T> {
}
}

#[cfg(feature = "std")]
#[cfg(all(feature = "std", not(target_os = "haiku")))]
impl<T: ShMem> Write for ShMemCursor<T> {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
match self.empty_slice_mut().write(buf) {
Expand Down

0 comments on commit bae24d9

Please sign in to comment.