From 4a84b2f04c4c856b5ef230bea4d9c90198a147f8 Mon Sep 17 00:00:00 2001 From: auronandace Date: Sat, 7 Feb 2026 14:58:02 +0000 Subject: [PATCH] tidy up lints and add zero_ptr --- Cargo.toml | 16 ++++++++++++++++ src/header/dlfcn/mod.rs | 3 ++- src/ld_so/debug.rs | 2 +- src/lib.rs | 14 -------------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 820c43a6b7..7bc4db4e39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,14 +20,30 @@ members = [ exclude = ["tests", "dlmalloc-rs"] [workspace.lints.clippy] +cast_lossless = "warn" +cast_ptr_alignment = "allow" # TODO change to warn or deny when ready to fix +mut_from_ref = "allow" ptr_as_ptr = "warn" ptr_cast_constness = "warn" ref_as_ptr = "warn" +zero_ptr = "warn" [lints.clippy] +cast_lossless = "warn" +cast_ptr_alignment = "allow" # TODO change to warn or deny when ready to fix +mut_from_ref = "allow" ptr_as_ptr = "warn" ptr_cast_constness = "warn" ref_as_ptr = "warn" +zero_ptr = "warn" + +[workspace.lints.rust] +non_camel_case_types = "allow" +unsafe_op_in_unsafe_fn = "deny" + +[lints.rust] +non_camel_case_types = "allow" +unsafe_op_in_unsafe_fn = "deny" [build-dependencies] cc = "1" diff --git a/src/header/dlfcn/mod.rs b/src/header/dlfcn/mod.rs index 118355b3f4..7bcc3c6535 100644 --- a/src/header/dlfcn/mod.rs +++ b/src/header/dlfcn/mod.rs @@ -26,7 +26,8 @@ pub const RTLD_NOLOAD: c_int = 1 << 2; pub const RTLD_GLOBAL: c_int = 1 << 8; pub const RTLD_LOCAL: c_int = 0x0000; -pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; // XXX: cbindgen doesn't like ptr::null_mut() +#[allow(clippy::zero_ptr)] // related cbindgen issue: https://github.com/mozilla/cbindgen/issues/948 +pub const RTLD_DEFAULT: *mut c_void = 0 as *mut c_void; // XXX: cbindgen doesn't like ptr::null_mut() for publically exported constants static ERROR_NOT_SUPPORTED: &core::ffi::CStr = c"dlfcn not supported"; diff --git a/src/ld_so/debug.rs b/src/ld_so/debug.rs index 30f2c0549c..72118876ff 100644 --- a/src/ld_so/debug.rs +++ b/src/ld_so/debug.rs @@ -39,7 +39,7 @@ pub struct RTLDDebug { impl RTLDDebug { const NEW: Self = RTLDDebug { r_version: 1, - r_map: 0 as *mut LinkMap, + r_map: ptr::null_mut::(), r_brk: _dl_debug_state, state: RTLDState::RT_CONSISTENT, r_ldbase: 0, diff --git a/src/lib.rs b/src/lib.rs index 1736cd073e..64651fe964 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,12 +8,8 @@ #![no_std] #![allow(warnings)] -#![allow(non_camel_case_types)] -#![allow(non_upper_case_globals)] -#![allow(unused_variables)] #![feature(alloc_error_handler)] #![feature(allocator_api)] -#![feature(asm_const)] #![feature(c_variadic)] #![feature(core_intrinsics)] #![feature(macro_derive)] @@ -22,22 +18,12 @@ #![feature(linkage)] #![feature(pointer_is_aligned_to)] #![feature(ptr_as_uninit)] -#![feature(slice_as_chunks)] #![feature(slice_ptr_get)] #![feature(stmt_expr_attributes)] -#![feature(strict_provenance)] #![feature(sync_unsafe_cell)] #![feature(thread_local)] #![feature(vec_into_raw_parts)] #![feature(negative_impls)] -#![allow(clippy::cast_lossless)] -#![allow(clippy::cast_ptr_alignment)] -#![allow(clippy::derive_hash_xor_eq)] -#![allow(clippy::eval_order_dependence)] -#![allow(clippy::mut_from_ref)] -#![deny(unsafe_op_in_unsafe_fn)] -// TODO: fix these -#![warn(unaligned_references)] #[macro_use] extern crate alloc;