@@ -23,6 +23,7 @@ pub unsafe fn environ() -> *const *const c_char {
2323 unsafe extern "C" {
2424 static environ: * const * const c_char ;
2525 }
26+ // SAFETY: environ is a valid global pointer to the process environment, as defined by POSIX
2627 unsafe { environ }
2728}
2829
@@ -143,8 +144,18 @@ unsafe extern "C" fn execvp(prog: *const c_char, argv: *const *const c_char) ->
143144
144145#[ cfg( target_os = "linux" ) ]
145146mod linux_only {
146- use std:: ops:: Deref ;
147-
147+ #[ expect(
148+ clippy:: useless_attribute,
149+ reason = "allow_attributes on use items is flagged as useless but needed here"
150+ ) ]
151+ #[ expect(
152+ clippy:: allow_attributes,
153+ reason = "using allow because wildcard_imports may or may not fire depending on build target"
154+ ) ]
155+ #[ allow(
156+ clippy:: wildcard_imports,
157+ reason = "macro-generated code requires types from parent scope"
158+ ) ]
148159 use super :: * ;
149160 use crate :: client:: convert:: { PathAt , ToAbsolutePath } ;
150161
@@ -158,6 +169,10 @@ mod linux_only {
158169 argv : * const * const libc:: c_char ,
159170 envp : * const * const libc:: c_char ,
160171 ) -> c_int {
172+ #[ expect(
173+ clippy:: no_effect_underscore_binding,
174+ reason = "suppresses unused warning on *::original"
175+ ) ]
161176 let _unused = execvpe:: original;
162177 handle_exec ( ExecResolveConfig :: search_path_enabled ( None ) , file, argv, envp)
163178 }
@@ -175,17 +190,23 @@ mod linux_only {
175190 envp : * const * mut libc:: c_char ,
176191 flags : c_int , // TODO: conform to semantics of flags
177192 ) -> libc:: c_int {
193+ #[ expect(
194+ clippy:: no_effect_underscore_binding,
195+ reason = "suppresses unused warning on *::original"
196+ ) ]
178197 let _unused = execveat:: original;
198+ // SAFETY: PathAt wraps a valid dirfd and pathname pointer from the interposed execveat call
179199 let abs_path_result = unsafe {
180200 PathAt ( dirfd, pathname) . to_absolute_path ( |path| {
181201 let Some ( path) = path else {
182202 return Ok ( None ) ;
183203 } ;
184- Ok ( Some ( CString :: new ( path. deref ( ) ) . unwrap ( ) ) )
204+ Ok ( Some ( CString :: new ( & * * path) . unwrap ( ) ) )
185205 } )
186206 } ;
187207 let abs_path = match abs_path_result {
188208 Ok ( None ) => {
209+ // SAFETY: forwarding the original arguments to the real execveat syscall
189210 return unsafe { execveat:: original ( ) ( dirfd, pathname, argv, envp, flags) } ;
190211 }
191212 Ok ( Some ( path) ) => path. as_ptr ( ) ,
@@ -207,8 +228,12 @@ mod linux_only {
207228 argv : * const * const libc:: c_char ,
208229 envp : * const * const libc:: c_char ,
209230 ) -> libc:: c_int {
231+ #[ expect(
232+ clippy:: no_effect_underscore_binding,
233+ reason = "suppresses unused warning on *::original"
234+ ) ]
210235 let _unused = fexecve:: original;
211- let prog = format ! ( "/proc/self/fd/{}\0 " , fd ) ;
236+ let prog = format ! ( "/proc/self/fd/{fd }\0 " ) ;
212237 let prog = prog. as_ptr ( ) ;
213238 handle_exec ( ExecResolveConfig :: search_path_disabled ( ) , prog. cast ( ) , argv, envp)
214239 }
0 commit comments