File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change 11//! Platform-dependent environment variables abstraction.
22
3- #![ deny ( unsafe_op_in_unsafe_fn) ]
3+ #![ forbid ( unsafe_op_in_unsafe_fn) ]
44
55cfg_if:: cfg_if! {
66 if #[ cfg( target_family = "unix" ) ] {
Original file line number Diff line number Diff line change 1- #![ allow( unsafe_op_in_unsafe_fn) ]
2-
31use core:: slice:: memchr;
42
53use libc:: c_char;
@@ -81,7 +79,7 @@ impl Iterator for Env {
8179// desirable anyhow? Though it also means that we have to link to Foundation.
8280#[ cfg( target_vendor = "apple" ) ]
8381pub unsafe fn environ ( ) -> * mut * const * const c_char {
84- libc:: _NSGetEnviron ( ) as * mut * const * const c_char
82+ unsafe { libc:: _NSGetEnviron ( ) as * mut * const * const c_char }
8583}
8684
8785// Use the `environ` static which is part of POSIX.
@@ -159,14 +157,14 @@ pub unsafe fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
159157 run_with_cstr ( k. as_bytes ( ) , & |k| {
160158 run_with_cstr ( v. as_bytes ( ) , & |v| {
161159 let _guard = ENV_LOCK . write ( ) ;
162- cvt ( libc:: setenv ( k. as_ptr ( ) , v. as_ptr ( ) , 1 ) ) . map ( drop)
160+ cvt ( unsafe { libc:: setenv ( k. as_ptr ( ) , v. as_ptr ( ) , 1 ) } ) . map ( drop)
163161 } )
164162 } )
165163}
166164
167165pub unsafe fn unsetenv ( n : & OsStr ) -> io:: Result < ( ) > {
168166 run_with_cstr ( n. as_bytes ( ) , & |nbuf| {
169167 let _guard = ENV_LOCK . write ( ) ;
170- cvt ( libc:: unsetenv ( nbuf. as_ptr ( ) ) ) . map ( drop)
168+ cvt ( unsafe { libc:: unsetenv ( nbuf. as_ptr ( ) ) } ) . map ( drop)
171169 } )
172170}
You can’t perform that action at this time.
0 commit comments