Skip to content

Commit bae24d9

Browse files
authored
bolts: haiku, addressing clippy warnings (#1647)
1 parent 56b37bb commit bae24d9

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

libafl_bolts/src/core_affinity.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,14 @@ mod linux {
350350
// FIXME: no sense of cpu granularity (yet ?)
351351

352352
#[cfg(target_os = "haiku")]
353+
#[allow(clippy::unnecessary_wraps)]
353354
#[inline]
354355
fn get_core_ids_helper() -> Result<Vec<CoreId>, Error> {
355356
Ok(Vec::new())
356357
}
357358

358359
#[cfg(target_os = "haiku")]
360+
#[allow(clippy::unnecessary_wraps)]
359361
#[inline]
360362
fn set_for_current_helper(_core_id: CoreId) -> Result<(), Error> {
361363
Ok(())

libafl_bolts/src/minibsod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ fn write_crash<W: Write>(
653653
_ucontext: &ucontext_t,
654654
) -> Result<(), std::io::Error> {
655655
// TODO add fault addr for other platforms.
656-
writeln!(writer, "Received signal {}", signal,)?;
656+
writeln!(writer, "Received signal {signal}")?;
657657

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

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

854855
loop {
855856
if unsafe { libc::get_next_image_info(0, &mut c, &mut info) } == libc::B_OK {
856857
let i = format!(
857858
"{}-{} {:?}\n",
858-
info.text as u64,
859-
info.text as u64 + info.text_size as u64,
859+
info.text as i64,
860+
info.text as i64 + i64::from(info.text_size),
860861
info.name
861862
);
862863
writer.write_all(&i.into_bytes())?;

libafl_bolts/src/shmem.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use core::fmt::Display;
1010
use core::{cell::RefCell, fmt, mem::ManuallyDrop};
1111
#[cfg(feature = "std")]
1212
use std::env;
13-
#[cfg(all(unix, feature = "std"))]
13+
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
1414
use std::io::Read;
15-
#[cfg(feature = "std")]
15+
#[cfg(all(feature = "std", not(target_os = "haiku")))]
1616
use std::io::Write;
1717

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

30-
#[cfg(all(unix, feature = "std"))]
30+
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
3131
use crate::os::pipes::Pipe;
3232
#[cfg(all(feature = "std", unix, not(target_os = "haiku")))]
3333
pub use crate::os::unix_shmem_server::{ServedShMemProvider, ShMemService};
@@ -411,7 +411,7 @@ impl<T: ShMemProvider> Drop for RcShMem<T> {
411411
/// that can use internal mutability.
412412
/// Useful if the `ShMemProvider` needs to keep local state.
413413
#[derive(Debug, Clone)]
414-
#[cfg(all(unix, feature = "std"))]
414+
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
415415
pub struct RcShMemProvider<SP>
416416
where
417417
SP: ShMemProvider,
@@ -505,7 +505,7 @@ where
505505
}
506506
}
507507

508-
#[cfg(all(unix, feature = "std"))]
508+
#[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
509509
impl<SP> RcShMemProvider<SP>
510510
where
511511
SP: ShMemProvider,
@@ -1457,7 +1457,7 @@ pub struct ShMemCursor<T: ShMem> {
14571457
pos: usize,
14581458
}
14591459

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

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

0 commit comments

Comments
 (0)