From 2c53eb1f6dacc036b2d70813e1f8d4ea40c08e3e Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 14 Feb 2026 16:48:39 +0000 Subject: [PATCH] add improper_ctypes_definitions lint --- Cargo.toml | 1 + src/header/arch_aarch64_user/mod.rs | 2 +- src/header/arch_x64_user/mod.rs | 2 +- src/header/sys_procfs/mod.rs | 2 +- src/header/unistd/mod.rs | 8 ++++---- src/lib.rs | 2 ++ 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 25fcd2da5e..1e62d039e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue [workspace.lints.rust] dangling_pointers_from_temporaries = "deny" +improper_ctypes_definitions = "deny" internal_features = "allow" # core_intrinsics and lang_items irrefutable_let_patterns = "deny" mismatched_lifetime_syntaxes = "deny" diff --git a/src/header/arch_aarch64_user/mod.rs b/src/header/arch_aarch64_user/mod.rs index de46c63e3c..5586c38bac 100644 --- a/src/header/arch_aarch64_user/mod.rs +++ b/src/header/arch_aarch64_user/mod.rs @@ -16,7 +16,7 @@ pub struct user_fpsimd_struct { } pub type elf_greg_t = c_ulong; -pub type elf_gregset_t = [c_ulong; 34]; +pub type elf_gregset_t = *mut [c_ulong; 34]; pub type elf_fpregset_t = user_fpsimd_struct; #[unsafe(no_mangle)] diff --git a/src/header/arch_x64_user/mod.rs b/src/header/arch_x64_user/mod.rs index 85114e9443..116b990282 100644 --- a/src/header/arch_x64_user/mod.rs +++ b/src/header/arch_x64_user/mod.rs @@ -50,7 +50,7 @@ pub struct user_regs_struct { pub type elf_greg_t = c_ulong; -pub type elf_gregset_t = [c_ulong; 27]; +pub type elf_gregset_t = *mut [c_ulong; 27]; pub type elf_fpregset_t = user_fpregs_struct; #[repr(C)] pub struct user { diff --git a/src/header/sys_procfs/mod.rs b/src/header/sys_procfs/mod.rs index 2de5e9ea3f..b1534b33f2 100644 --- a/src/header/sys_procfs/mod.rs +++ b/src/header/sys_procfs/mod.rs @@ -59,7 +59,7 @@ pub struct elf_prpsinfo { } pub type psaddr_t = *mut c_void; -pub type prgregset_t = elf_gregset_t; +pub type prgregset_t = *mut elf_gregset_t; pub type prfpregset_t = elf_fpregset_t; pub type lwpid_t = pid_t; pub type prstatus_t = elf_prstatus; diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 4e3e6a95f9..3f98fad564 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -282,11 +282,11 @@ pub extern "C" fn dup3(fildes: c_int, fildes2: c_int, flag: c_int) -> c_int { /// /// # Deprecation /// The `encrypt()` function was marked obsolescent in the Open Group Base Specifications Issue 8. -#[deprecated] +//#[deprecated] // #[unsafe(no_mangle)] -pub extern "C" fn encrypt(block: [c_char; 64], edflag: c_int) { - unimplemented!(); -} +//pub extern "C" fn encrypt(block: [c_char; 64], edflag: c_int) { +// unimplemented!(); +//} /// See . #[unsafe(no_mangle)] diff --git a/src/lib.rs b/src/lib.rs index 91a907de79..cb8e7f0652 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,8 +88,10 @@ pub extern "C" fn rust_eh_personality() {} #[cfg(not(test))] #[alloc_error_handler] #[linkage = "weak"] +#[allow(improper_ctypes_definitions)] #[unsafe(no_mangle)] pub extern "C" fn rust_oom(layout: ::core::alloc::Layout) -> ! { + // Layout not FFI-safe? use core::fmt::Write; let mut w = platform::FileWriter::new(2);