spawn header cleanup
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
sys_includes = ["sched.h", "bits/sigset-t.h", "bits/mode-t.h", "bits/size-t.h"]
|
||||
include_guard = "_RELIBC_SPAWN_H"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
no_includes = true
|
||||
cpp_compat = true
|
||||
|
||||
[enum]
|
||||
|
||||
@@ -59,14 +59,14 @@ impl Iterator for FileActionsIter {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoIterator for &'a posix_spawn_file_actions_t {
|
||||
impl IntoIterator for &posix_spawn_file_actions_t {
|
||||
type Item = Action;
|
||||
|
||||
type IntoIter = FileActionsIter;
|
||||
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
FileActionsIter {
|
||||
actions: (*self).clone(),
|
||||
actions: (*self),
|
||||
curr: 0,
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,7 @@ pub unsafe extern "C" fn posix_spawn_file_actions_addopen(
|
||||
path: if path.is_null() {
|
||||
CString::new("").unwrap()
|
||||
} else {
|
||||
unsafe { CString::from_raw(path as *mut c_char) }
|
||||
unsafe { CString::from_raw(path.cast_mut()) }
|
||||
},
|
||||
flag: oflag,
|
||||
mode,
|
||||
@@ -175,7 +175,7 @@ pub unsafe extern "C" fn posix_spawn_file_actions_addchdir(
|
||||
if path.is_null() {
|
||||
CString::new("").unwrap()
|
||||
} else {
|
||||
CString::from_raw(path as *mut c_char)
|
||||
CString::from_raw(path.cast_mut())
|
||||
}
|
||||
}));
|
||||
0
|
||||
|
||||
@@ -42,7 +42,7 @@ unsafe fn spawn(
|
||||
) -> Result<()> {
|
||||
let mut original_cwd = [0 as c_char; PATH_MAX];
|
||||
assert!(
|
||||
unsafe { !getcwd(original_cwd.as_mut_ptr() as *mut c_char, PATH_MAX).is_null() },
|
||||
unsafe { !getcwd(original_cwd.as_mut_ptr().cast::<c_char>(), PATH_MAX).is_null() },
|
||||
"Error getting cwd: {}",
|
||||
ERRNO.get()
|
||||
);
|
||||
@@ -57,7 +57,7 @@ unsafe fn spawn(
|
||||
'a: for path_element in path_elements {
|
||||
let pe = CString::from_str(path_element).unwrap();
|
||||
let dir = if let Some(dir) =
|
||||
unsafe { opendir(pe.as_bytes_with_nul().as_ptr() as *const c_char).as_mut() }
|
||||
unsafe { opendir(pe.as_bytes_with_nul().as_ptr().cast::<c_char>()).as_mut() }
|
||||
{
|
||||
dir
|
||||
} else if ERRNO.get() == 0 || ERRNO.get() == ENOTDIR || ERRNO.get() == ENOENT {
|
||||
@@ -68,7 +68,7 @@ unsafe fn spawn(
|
||||
|
||||
while let Some(dir_ent) = unsafe { readdir(dir).as_ref() } {
|
||||
let dir_ent_name = unsafe {
|
||||
CStr::from_ptr(dir_ent.d_name.as_ptr() as *const c_char)
|
||||
CStr::from_ptr(dir_ent.d_name.as_ptr().cast::<c_char>())
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
@@ -103,12 +103,11 @@ unsafe fn spawn(
|
||||
*pid = v;
|
||||
}
|
||||
})
|
||||
.map_err(|e| {
|
||||
let status = chdir(original_cwd.as_ptr() as *const c_char);
|
||||
.inspect_err(|e| {
|
||||
let status = chdir(original_cwd.as_ptr().cast::<c_char>());
|
||||
if status != 0 {
|
||||
panic!("Error switching back to original cwd: {}", ERRNO.get());
|
||||
}
|
||||
e
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -209,7 +208,7 @@ pub unsafe extern "C" fn posix_spawnp(
|
||||
attrp.as_ref(),
|
||||
argv,
|
||||
envp,
|
||||
if program.contains('/') { false } else { true },
|
||||
!program.contains('/'),
|
||||
)
|
||||
} {
|
||||
return e.0;
|
||||
|
||||
@@ -81,7 +81,7 @@ pub unsafe extern "C" fn posix_spawnattr_setschedparam(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let schedparam = unsafe { schedparam.as_ref().expect("schedparam cannot be NULL") };
|
||||
(*attr).param = *schedparam;
|
||||
attr.param = *schedparam;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ pub unsafe extern "C" fn posix_spawnattr_getschedparam(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let schedparam = unsafe { schedparam.as_mut().expect("schedparam cannot be NULL") };
|
||||
*schedparam = (*attr).param;
|
||||
*schedparam = attr.param;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ pub unsafe extern "C" fn posix_spawnattr_setschedpolicy(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
match schedpolicy {
|
||||
SCHED_FIFO | SCHED_RR | SCHED_OTHER => (*attr).policy = schedpolicy,
|
||||
SCHED_FIFO | SCHED_RR | SCHED_OTHER => attr.policy = schedpolicy,
|
||||
_ => return EINVAL,
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ pub unsafe extern "C" fn posix_spawnattr_getschedpolicy(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let schedpolicy = unsafe { schedpolicy.as_mut().expect("schedpolicy cannot be NULL") };
|
||||
*schedpolicy = (*attr).policy;
|
||||
*schedpolicy = attr.policy;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ pub unsafe extern "C" fn posix_spawnattr_setsigdefault(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let sigdefault = unsafe { sigdefault.as_ref().expect("sigdefault cannot be NULL") };
|
||||
(*attr).sigdefault = *sigdefault;
|
||||
attr.sigdefault = *sigdefault;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ pub unsafe extern "C" fn posix_spawnattr_getsigdefault(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let sigdefault = unsafe { sigdefault.as_mut().expect("sigdefault cannot be NULL") };
|
||||
*sigdefault = (*attr).sigdefault;
|
||||
*sigdefault = attr.sigdefault;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ pub unsafe extern "C" fn posix_spawnattr_setsigmask(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let sigmask = unsafe { sigmask.as_ref().expect("sigmask cannot be NULL") };
|
||||
(*attr).sigmask = *sigmask;
|
||||
attr.sigmask = *sigmask;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -203,7 +203,7 @@ pub unsafe extern "C" fn posix_spawnattr_getsigmask(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let sigmask = unsafe { sigmask.as_mut().expect("sigmask cannot be NULL") };
|
||||
*sigmask = (*attr).sigmask;
|
||||
*sigmask = attr.sigmask;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ pub unsafe extern "C" fn posix_spawnattr_setflags(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
match Flags::from_bits(flags) {
|
||||
Some(v) => (*attr).flags = v.bits(),
|
||||
Some(v) => attr.flags = v.bits(),
|
||||
None => {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -243,7 +243,7 @@ pub unsafe extern "C" fn posix_spawnattr_getflags(
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let flags = unsafe { flags.as_mut().expect("flags cannot be NULL") };
|
||||
|
||||
*flags = (*attr).flags;
|
||||
*flags = attr.flags;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ pub unsafe extern "C" fn posix_spawnattr_setpgroup(
|
||||
pgroup: pid_t,
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_mut().expect("posix_spawnattr_t cannot be NULL") };
|
||||
(*attr).pgroup = pgroup;
|
||||
attr.pgroup = pgroup;
|
||||
0
|
||||
}
|
||||
|
||||
@@ -276,6 +276,6 @@ pub unsafe extern "C" fn posix_spawnattr_getpgroup(
|
||||
) -> c_int {
|
||||
let attr = unsafe { attr.as_ref().expect("posix_spawnattr_t cannot be NULL") };
|
||||
let pgroup = unsafe { pgroup.as_mut().expect("pgroup cannot be NULL") };
|
||||
*pgroup = (*attr).pgroup;
|
||||
*pgroup = attr.pgroup;
|
||||
0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user