tackle various clippy lints
This commit is contained in:
@@ -64,10 +64,10 @@ pub unsafe extern "C" fn inet_aton(cp: *const c_char, inp: *mut in_addr) -> c_in
|
||||
// While it is true that C2Y accepts 0o and 0O as octal prefixes, C17 doesn't
|
||||
// The POSIX spec defers to C17
|
||||
// see https://pubs.opengroup.org/onlinepubs/9799919799/functions/inet_addr.html
|
||||
_ => u32::from_str_radix(&hex_or_oct, 8),
|
||||
_ => u32::from_str_radix(hex_or_oct, 8),
|
||||
}
|
||||
} else {
|
||||
u32::from_str_radix(&part, 10)
|
||||
part.parse::<u32>()
|
||||
}
|
||||
} {
|
||||
if parts_iter.peek().is_some() {
|
||||
|
||||
@@ -288,11 +288,7 @@ impl PosixLocaleDef {
|
||||
let mut locale = PosixLocaleDef::default();
|
||||
|
||||
let mut lines = content.lines();
|
||||
loop {
|
||||
let Some(line) = lines.next() else {
|
||||
break;
|
||||
};
|
||||
|
||||
while let Some(line) = lines.next() {
|
||||
let trimmed = line.trim();
|
||||
if trimmed.is_empty() || trimmed.starts_with('#') {
|
||||
continue;
|
||||
@@ -303,10 +299,7 @@ impl PosixLocaleDef {
|
||||
continue;
|
||||
};
|
||||
let mut val: String = String::new();
|
||||
loop {
|
||||
let Some(chunk) = parts.next() else {
|
||||
break;
|
||||
};
|
||||
while let Some(chunk) = parts.next() {
|
||||
if !chunk.ends_with('\\') {
|
||||
val.push_str(chunk);
|
||||
break;
|
||||
|
||||
@@ -42,7 +42,7 @@ unsafe fn openpty_inner(name: &mut [u8]) -> Result<(c_int, c_int), ()> {
|
||||
|
||||
let slave = unsafe {
|
||||
fcntl::open(
|
||||
name.as_ptr() as *const c_char,
|
||||
name.as_ptr().cast::<c_char>(),
|
||||
fcntl::O_RDWR | fcntl::O_NOCTTY,
|
||||
0,
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@ pub const F_SVB: c_int = 64;
|
||||
pub const F_APP: c_int = 128;
|
||||
pub const F_BADJ: c_int = 256;
|
||||
|
||||
/// SEEK_SET, SEEK_CUR and SEEK_END defined in fcntl bits header
|
||||
// SEEK_SET, SEEK_CUR and SEEK_END defined in fcntl bits header
|
||||
|
||||
pub const _IOFBF: c_int = 0;
|
||||
pub const _IOLBF: c_int = 1;
|
||||
|
||||
@@ -192,11 +192,11 @@ impl VaArg {
|
||||
}
|
||||
|
||||
let ap_impl = unsafe {
|
||||
let ptr_to_struct = ap as *mut core::ffi::VaList as *mut VaListInner;
|
||||
let ptr_to_struct = core::ptr::from_mut::<core::ffi::VaList>(ap).cast::<VaListInner>();
|
||||
&mut *ptr_to_struct
|
||||
};
|
||||
|
||||
let ptr = ap_impl.overflow_arg_area as *const c_longdouble;
|
||||
let ptr = ap_impl.overflow_arg_area.cast::<c_longdouble>();
|
||||
let val = unsafe { ptr.read() };
|
||||
|
||||
ap_impl.overflow_arg_area = unsafe { ap_impl.overflow_arg_area.add(16) };
|
||||
|
||||
@@ -368,7 +368,7 @@ pub unsafe extern "C" fn exit(status: c_int) -> ! {
|
||||
}
|
||||
|
||||
// Look for the neighbor functions in memory until the end
|
||||
let mut f = unsafe { &__fini_array_end } as *const _;
|
||||
let mut f = core::ptr::from_ref(unsafe { &__fini_array_end });
|
||||
#[allow(clippy::op_ref)]
|
||||
while f > &raw const __fini_array_start {
|
||||
f = unsafe { f.offset(-1) };
|
||||
|
||||
@@ -38,7 +38,7 @@ pub struct fd_set {
|
||||
}
|
||||
|
||||
#[allow(clippy::needless_update)]
|
||||
pub fn select_epoll(
|
||||
pub unsafe fn select_epoll(
|
||||
nfds: c_int,
|
||||
readfds: Option<&mut fd_set>,
|
||||
writefds: Option<&mut fd_set>,
|
||||
@@ -188,30 +188,32 @@ pub unsafe extern "C" fn select(
|
||||
timeout: *mut timeval,
|
||||
) -> c_int {
|
||||
trace_expr!(
|
||||
select_epoll(
|
||||
nfds,
|
||||
if readfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *readfds })
|
||||
},
|
||||
if writefds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *writefds })
|
||||
},
|
||||
if exceptfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *exceptfds })
|
||||
},
|
||||
if timeout.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *timeout })
|
||||
},
|
||||
core::ptr::null(),
|
||||
),
|
||||
unsafe {
|
||||
select_epoll(
|
||||
nfds,
|
||||
if readfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *readfds)
|
||||
},
|
||||
if writefds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *writefds)
|
||||
},
|
||||
if exceptfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *exceptfds)
|
||||
},
|
||||
if timeout.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *timeout)
|
||||
},
|
||||
core::ptr::null(),
|
||||
)
|
||||
},
|
||||
"select({}, {:p}, {:p}, {:p}, {:p})",
|
||||
nfds,
|
||||
readfds,
|
||||
@@ -242,26 +244,28 @@ pub unsafe extern "C" fn pselect(
|
||||
}
|
||||
};
|
||||
trace_expr!(
|
||||
select_epoll(
|
||||
nfds,
|
||||
if readfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *readfds })
|
||||
},
|
||||
if writefds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *writefds })
|
||||
},
|
||||
if exceptfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { &mut *exceptfds })
|
||||
},
|
||||
micro_timeout.as_mut(),
|
||||
sigmask
|
||||
),
|
||||
unsafe {
|
||||
select_epoll(
|
||||
nfds,
|
||||
if readfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *readfds)
|
||||
},
|
||||
if writefds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *writefds)
|
||||
},
|
||||
if exceptfds.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut *exceptfds)
|
||||
},
|
||||
micro_timeout.as_mut(),
|
||||
sigmask,
|
||||
)
|
||||
},
|
||||
"pselect({}, {:p}, {:p}, {:p}, {:p}, {:p})",
|
||||
nfds,
|
||||
readfds,
|
||||
|
||||
@@ -137,9 +137,9 @@ pub unsafe extern "C" fn mtx_destroy(mtx: *mut mtx_t) {
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn mtx_init(mtx: *mut mtx_t, ty: c_int) -> c_int {
|
||||
let mut attr = MaybeUninit::<pthread_mutexattr_t>::uninit();
|
||||
let _ = unsafe {
|
||||
unsafe {
|
||||
pthread_mutexattr_init(attr.as_mut_ptr());
|
||||
};
|
||||
}
|
||||
let mut attr = unsafe { attr.assume_init() };
|
||||
|
||||
let _ = unsafe {
|
||||
@@ -260,7 +260,7 @@ pub unsafe extern "C" fn thrd_exit(ret: c_int) -> ! {
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/thrd_join.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn thrd_join(thrd: thrd_t, retval: *mut c_int) -> c_int {
|
||||
if unsafe { pthread_join(thrd, retval as *mut *mut c_void) } == 0 {
|
||||
if unsafe { pthread_join(thrd, retval.cast::<*mut c_void>()) } == 0 {
|
||||
thrd_success
|
||||
} else {
|
||||
thrd_error
|
||||
|
||||
@@ -823,7 +823,7 @@ pub extern "C" fn nice(incr: c_int) -> c_int {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return new_nice;
|
||||
new_nice
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/pause.html>.
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ impl Write for StringWriter {
|
||||
if self.1 > 1 {
|
||||
let copy_size = buf.len().min(self.1 - 1);
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(buf.as_ptr() as _, self.0, copy_size);
|
||||
ptr::copy_nonoverlapping(buf.as_ptr().cast(), self.0, copy_size);
|
||||
self.1 -= copy_size;
|
||||
|
||||
self.0 = self.0.add(copy_size);
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ pub unsafe fn init() {
|
||||
//const FIRST_THREAD_IDX: usize = 1;
|
||||
|
||||
pub unsafe fn terminate_from_main_thread() {
|
||||
for (_, tcb) in OS_TID_TO_PTHREAD.lock().iter() {
|
||||
for tcb in OS_TID_TO_PTHREAD.lock().values() {
|
||||
let _ = unsafe { cancel(&(*tcb.0).pthread) };
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -235,7 +235,7 @@ pub unsafe extern "C" fn relibc_start_v1(
|
||||
|
||||
// Run preinit array
|
||||
{
|
||||
let mut f = unsafe { &__preinit_array_start } as *const _;
|
||||
let mut f = core::ptr::from_ref(unsafe { &__preinit_array_start });
|
||||
#[allow(clippy::op_ref)]
|
||||
while f < &raw const __preinit_array_end {
|
||||
(unsafe { *f })();
|
||||
@@ -245,7 +245,7 @@ pub unsafe extern "C" fn relibc_start_v1(
|
||||
|
||||
// Run init array
|
||||
{
|
||||
let mut f = unsafe { &__init_array_start } as *const _;
|
||||
let mut f = core::ptr::from_ref(unsafe { &__init_array_start });
|
||||
#[allow(clippy::op_ref)]
|
||||
while f < &raw const __init_array_end {
|
||||
(unsafe { *f })();
|
||||
|
||||
Reference in New Issue
Block a user