diff --git a/Cargo.toml b/Cargo.toml index 5045934037..dfe06ad86d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ precedence = "deny" ptr_as_ptr = "warn" # TODO review occurrences ptr_cast_constness = "warn" # TODO review occurrences ref_as_ptr = "warn" # TODO review occurrences +upper_case_acronyms = "allow" # TODO review occurrences zero_ptr = "warn" # must allow on public constants due to cbindgen issue [workspace.lints.rust] diff --git a/src/header/utmp/mod.rs b/src/header/utmp/mod.rs index 0b3dfdf555..8512050b29 100644 --- a/src/header/utmp/mod.rs +++ b/src/header/utmp/mod.rs @@ -19,7 +19,7 @@ pub unsafe extern "C" fn login_tty(fd: c_int) -> c_int { sys_ioctl::ioctl( fd, sys_ioctl::TIOCSCTTY, - &mut arg as *mut c_int as *mut c_void, + core::ptr::from_mut::(&mut arg).cast::(), ) } != 0 { diff --git a/src/header/wchar/lookaheadreader.rs b/src/header/wchar/lookaheadreader.rs index f3eae9f973..308bb6352f 100644 --- a/src/header/wchar/lookaheadreader.rs +++ b/src/header/wchar/lookaheadreader.rs @@ -88,7 +88,7 @@ impl<'a> LookAheadFile<'a> { unsafe { mbrtowc( &mut wc, - buf.as_ptr() as *const c_char, + buf.as_ptr().cast::(), encoded_length, ptr::null_mut(), ); diff --git a/src/header/wchar/mod.rs b/src/header/wchar/mod.rs index 405e2b5cd2..2917afa9fb 100644 --- a/src/header/wchar/mod.rs +++ b/src/header/wchar/mod.rs @@ -2,7 +2,7 @@ //! //! See . -use core::{char, ffi::VaList as va_list, mem, ptr, slice, usize}; +use core::{char, ffi::VaList as va_list, mem, ptr, slice}; use crate::{ c_str::WStr, diff --git a/src/header/wchar/utf8.rs b/src/header/wchar/utf8.rs index 191bb3cb0b..dc0da1f94a 100644 --- a/src/header/wchar/utf8.rs +++ b/src/header/wchar/utf8.rs @@ -1,7 +1,7 @@ //UTF implementation parts for wchar.h. //Partially ported from the Sortix libc -use core::{char, slice, str, usize}; +use core::{char, slice, str}; use crate::{ header::errno, @@ -55,7 +55,7 @@ pub unsafe fn mbrtowc(pwc: *mut wchar_t, s: *const c_char, n: usize, ps: *mut mb return -1isize as usize; } - let slice = unsafe { slice::from_raw_parts(s as *const u8, size) }; + let slice = unsafe { slice::from_raw_parts(s.cast::(), size) }; let decoded = str::from_utf8(slice); if decoded.is_err() { platform::ERRNO.set(errno::EILSEQ); @@ -84,7 +84,7 @@ pub unsafe fn wcrtomb(s: *mut c_char, wc: wchar_t, ps: *mut mbstate_t) -> usize let c = dc.unwrap(); let size = c.len_utf8(); - let slice = unsafe { slice::from_raw_parts_mut(s as *mut u8, size) }; + let slice = unsafe { slice::from_raw_parts_mut(s.cast::(), size) }; c.encode_utf8(slice); diff --git a/src/header/wchar/wscanf.rs b/src/header/wchar/wscanf.rs index c21f4993e1..43b5c2aa85 100644 --- a/src/header/wchar/wscanf.rs +++ b/src/header/wchar/wscanf.rs @@ -475,8 +475,7 @@ unsafe fn inner_scanf( // While we haven't used up all the width, and it matches let mut data_stored = false; - while width.map(|w| w > 0).unwrap_or(true) - && !invert == matches.contains(&wchar) + while width.map(|w| w > 0).unwrap_or(true) && invert != matches.contains(&wchar) { if let Some(ref mut ptr) = ptr { unsafe { **ptr = wchar as c_char }; diff --git a/src/header/wctype/alpha.rs b/src/header/wctype/alpha.rs index 621046e069..02c398b0e3 100644 --- a/src/header/wctype/alpha.rs +++ b/src/header/wctype/alpha.rs @@ -11,7 +11,7 @@ pub fn is(wc: usize) -> c_uchar { if wc < 0x2fffe { return 1; } - return 0; + 0 } const table: [c_uchar; 3904] = [ diff --git a/src/header/wctype/casecmp.rs b/src/header/wctype/casecmp.rs index e2479e7e72..4c25080911 100644 --- a/src/header/wctype/casecmp.rs +++ b/src/header/wctype/casecmp.rs @@ -410,5 +410,5 @@ pub fn casemap(mut c: u32, dir: i32) -> wint_t { xn -= xn / 2; } } - return c0; + c0 } diff --git a/src/header/wctype/punct.rs b/src/header/wctype/punct.rs index 140a21a659..2bfb1fc65a 100644 --- a/src/header/wctype/punct.rs +++ b/src/header/wctype/punct.rs @@ -8,7 +8,7 @@ pub fn is(wc: usize) -> c_uchar { if wc < 0x20000 { return (table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1; } - return 0; + 0 } const table: [c_uchar; 4000] = [ diff --git a/src/ld_so/dso.rs b/src/ld_so/dso.rs index 6dfa71df71..592ac89f43 100644 --- a/src/ld_so/dso.rs +++ b/src/ld_so/dso.rs @@ -353,9 +353,9 @@ pub struct DSO { } impl DSO { - pub fn new<'a>( + pub fn new( path: &str, - data: &'a [u8], + data: &[u8], base_addr: Option, dlopened: bool, id: usize,