@@ -12,26 +12,17 @@ use memchr::memchr;
1212use crate :: errno:: errno;
1313use crate :: error:: { Error , Result } ;
1414
15- /// This macro is used whenever we call a C function but
16- /// strongly believe that it cannot cause any memory unsafety.
17- #[ macro_export]
18- macro_rules! checked_ffi {
19- ( $e: expr) => {
20- unsafe { $e }
21- } ;
22- }
23-
2415/// Gets the effective user ID of the calling process
2516fn effective_user_id ( ) -> u32 {
2617 // Safety: the POSIX Programmer's Manual states that
2718 // geteuid will always be successful.
28- checked_ffi ! { libc:: geteuid( ) }
19+ unsafe { libc:: geteuid ( ) }
2920}
3021
3122/// Gets the process group of the process
3223/// with the given PID.
3324pub fn get_process_group ( pid : i32 ) -> Result < i32 > {
34- let pgid = checked_ffi ! { getpgid( pid) } ;
25+ let pgid = unsafe { getpgid ( pid) } ;
3526 if pgid == -1 {
3627 return Err ( match errno ( ) {
3728 EPERM => Error :: NoPermission ,
@@ -53,7 +44,7 @@ pub fn running_as_sudo() -> bool {
5344pub fn page_size ( ) -> Result < i64 > {
5445 // _SC_PAGESIZE is defined in POSIX.1
5546 // Safety: no memory unsafety can arise from `sysconf`
56- let page_size = checked_ffi ! { sysconf( _SC_PAGESIZE) } ;
47+ let page_size = unsafe { sysconf ( _SC_PAGESIZE) } ;
5748 if page_size == -1 {
5849 return Err ( Error :: SysConfFailed ) ;
5950 }
0 commit comments