tackle more clippy lints
This commit is contained in:
@@ -76,7 +76,7 @@ macro_rules! pthread_assert_equal_size(
|
||||
|
||||
// Fail at compile-time if alignments differ.
|
||||
let a = [0_u8; core::mem::align_of::<$export>()];
|
||||
#[allow(clippy::useless_transmute)]
|
||||
#[expect(clippy::useless_transmute)]
|
||||
let b: [u8; core::mem::align_of::<Wrapped>()] = core::mem::transmute(a);
|
||||
};
|
||||
// TODO: Turn into a macro?
|
||||
@@ -88,6 +88,7 @@ macro_rules! pthread_assert_equal_size(
|
||||
let _: libc::$export = core::mem::transmute(export.__relibc_internal_size);
|
||||
|
||||
let a = [0_u8; core::mem::align_of::<$export>()];
|
||||
#[expect(clippy::useless_transmute)]
|
||||
let b: [u8; core::mem::align_of::<libc::$export>()] = core::mem::transmute(a);
|
||||
|
||||
};
|
||||
|
||||
@@ -381,6 +381,7 @@ pub struct DSO {
|
||||
}
|
||||
|
||||
impl DSO {
|
||||
#[expect(clippy::not_unsafe_ptr_arg_deref, reason = "see FIXME note")]
|
||||
pub fn from_raw(
|
||||
base: *const u8,
|
||||
dyns: &[Dyn],
|
||||
|
||||
+1
-5
@@ -604,11 +604,7 @@ impl Linker {
|
||||
)?;
|
||||
|
||||
for (i, obj) in new_objects.iter().enumerate() {
|
||||
obj.relocate(
|
||||
objects_data[i].as_ref().map(|phdrs| phdrs.as_slice()),
|
||||
resolve,
|
||||
)
|
||||
.unwrap();
|
||||
obj.relocate(objects_data[i].as_deref(), resolve).unwrap();
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
||||
@@ -7,7 +7,7 @@ use log::{LevelFilter, Metadata, Record, SetLoggerError};
|
||||
|
||||
const DEFAULT_LOG_LEVEL: log::LevelFilter = log::LevelFilter::Info;
|
||||
|
||||
pub const RELIBC_LOG_ENV_VAR: &'static core::ffi::CStr = c"RELIBC_LOG_LEVEL";
|
||||
pub const RELIBC_LOG_ENV_VAR: &core::ffi::CStr = c"RELIBC_LOG_LEVEL";
|
||||
|
||||
pub unsafe fn init(level: LevelFilter) -> Result<(), SetLoggerError> {
|
||||
let mut logger = RedoxLogger::new();
|
||||
|
||||
@@ -129,7 +129,14 @@ pub unsafe fn fstat(fd: usize, buf: *mut crate::header::sys_stat::stat) -> Resul
|
||||
// TODO st_rdev
|
||||
buf.st_rdev = 0;
|
||||
buf.st_size = redox_buf.st_size as off_t;
|
||||
buf.st_blksize = redox_buf.st_blksize as blksize_t;
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
{
|
||||
buf.st_blksize = redox_buf.st_blksize as blksize_t;
|
||||
}
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
{
|
||||
buf.st_blksize = blksize_t::from(redox_buf.st_blksize);
|
||||
}
|
||||
buf.st_blocks = redox_buf.st_blocks as blkcnt_t;
|
||||
buf.st_atim = timespec {
|
||||
tv_sec: redox_buf.st_atime as time_t,
|
||||
|
||||
@@ -1800,6 +1800,7 @@ impl Pal for Sys {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[expect(clippy::unnecessary_literal_unwrap, reason = "res needs refactoring")]
|
||||
fn waitpid(pid: pid_t, stat_loc: Option<Out<'_, c_int>>, options: c_int) -> Result<pid_t> {
|
||||
let res = None;
|
||||
let mut status = 0;
|
||||
|
||||
@@ -309,12 +309,21 @@ pub struct FileLock(c_int);
|
||||
|
||||
impl FileLock {
|
||||
pub fn lock(fd: c_int, op: c_int) -> Result<Self> {
|
||||
if op & sys_file::LOCK_SH | sys_file::LOCK_EX == 0 {
|
||||
return Err(Error::new(EINVAL));
|
||||
const LOCK_SH_NB: c_int = sys_file::LOCK_SH | sys_file::LOCK_NB;
|
||||
const LOCK_EX_NB: c_int = sys_file::LOCK_EX | sys_file::LOCK_NB;
|
||||
const LOCK_UN_NB: c_int = sys_file::LOCK_UN | sys_file::LOCK_NB;
|
||||
match op {
|
||||
sys_file::LOCK_SH
|
||||
| sys_file::LOCK_EX
|
||||
| sys_file::LOCK_UN
|
||||
| LOCK_SH_NB
|
||||
| LOCK_EX_NB
|
||||
| LOCK_UN_NB => {
|
||||
Sys::flock(fd, op)?;
|
||||
Ok(Self(fd))
|
||||
}
|
||||
_ => Err(Error::new(EINVAL)),
|
||||
}
|
||||
|
||||
Sys::flock(fd, op)?;
|
||||
Ok(Self(fd))
|
||||
}
|
||||
|
||||
pub fn unlock(self) -> Result<()> {
|
||||
|
||||
@@ -78,7 +78,7 @@ unsafe fn bind_or_connect(
|
||||
}
|
||||
SocketCall::Connect => {
|
||||
// When a connect is made using AF_UNSPEC TCP and UDP need to disconnect from the default peer
|
||||
format!("disconnect")
|
||||
"disconnect".to_string()
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
|
||||
+3
-5
@@ -226,12 +226,10 @@ pub unsafe extern "C" fn relibc_start_v1(
|
||||
if let Some(env) = unsafe {
|
||||
CStr::from_nullable_ptr(crate::header::stdlib::getenv(RELIBC_LOG_ENV_VAR.as_ptr()))
|
||||
} && let Ok(level) = log::LevelFilter::from_str(env.to_str().unwrap_or(""))
|
||||
&& let Err(_) = unsafe { crate::platform::logger::init(level) }
|
||||
&& !is_dynamically_linked
|
||||
{
|
||||
if let Err(_) = unsafe { crate::platform::logger::init(level) }
|
||||
&& !is_dynamically_linked
|
||||
{
|
||||
log::error!("Logger has already been initialised");
|
||||
}
|
||||
log::error!("Logger has already been initialised");
|
||||
}
|
||||
|
||||
// Run preinit array
|
||||
|
||||
Reference in New Issue
Block a user