Fix clippy.sh script and fix a number of clippy warnings
This commit is contained in:
+13
-11
@@ -76,18 +76,20 @@ impl Context {
|
||||
if !self.loadable {
|
||||
return false;
|
||||
}
|
||||
let old = unsafe { &*(self.fx as *const FloatRegisters) };
|
||||
new._reserved = old._reserved;
|
||||
let old_st = new.st_space;
|
||||
let mut new_st = new.st_space;
|
||||
for (new_st, old_st) in new_st.iter_mut().zip(&old_st) {
|
||||
*new_st &= !ST_RESERVED;
|
||||
*new_st |= old_st & ST_RESERVED;
|
||||
}
|
||||
new.st_space = new_st;
|
||||
|
||||
// Make sure we don't use `old` from now on
|
||||
drop(old);
|
||||
{
|
||||
let old = unsafe { &*(self.fx as *const FloatRegisters) };
|
||||
new._reserved = old._reserved;
|
||||
let old_st = new.st_space;
|
||||
let mut new_st = new.st_space;
|
||||
for (new_st, old_st) in new_st.iter_mut().zip(&old_st) {
|
||||
*new_st &= !ST_RESERVED;
|
||||
*new_st |= old_st & ST_RESERVED;
|
||||
}
|
||||
new.st_space = new_st;
|
||||
|
||||
// Make sure we don't use `old` from now on
|
||||
}
|
||||
|
||||
unsafe {
|
||||
*(self.fx as *mut FloatRegisters) = new;
|
||||
|
||||
@@ -183,7 +183,7 @@ impl Context {
|
||||
let syscall_tail = unsafe { Box::from_raw(crate::ALLOCATOR.alloc(Layout::from_size_align_unchecked(PAGE_SIZE, PAGE_SIZE)) as *mut [u8; PAGE_SIZE]) };
|
||||
|
||||
Context {
|
||||
id: id,
|
||||
id,
|
||||
pgid: id,
|
||||
ppid: ContextId::from(0),
|
||||
ruid: 0,
|
||||
@@ -198,8 +198,8 @@ impl Context {
|
||||
running: false,
|
||||
cpu_id: None,
|
||||
syscall: None,
|
||||
syscall_head: syscall_head,
|
||||
syscall_tail: syscall_tail,
|
||||
syscall_head,
|
||||
syscall_tail,
|
||||
vfork: false,
|
||||
waitpid: Arc::new(WaitMap::new()),
|
||||
pending: VecDeque::new(),
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ impl ContextList {
|
||||
let offset = stack.len() - mem::size_of::<usize>();
|
||||
unsafe {
|
||||
let offset = stack.len() - mem::size_of::<usize>();
|
||||
let func_ptr = stack.as_mut_ptr().offset(offset as isize);
|
||||
let func_ptr = stack.as_mut_ptr().add(offset);
|
||||
*(func_ptr as *mut usize) = func as usize;
|
||||
}
|
||||
context.arch.set_page_table(unsafe { paging::ActivePageTable::new().address() });
|
||||
|
||||
@@ -312,9 +312,9 @@ pub struct Memory {
|
||||
impl Memory {
|
||||
pub fn new(start: VirtualAddress, size: usize, flags: EntryFlags, clear: bool) -> Self {
|
||||
let mut memory = Memory {
|
||||
start: start,
|
||||
size: size,
|
||||
flags: flags
|
||||
start,
|
||||
size,
|
||||
flags,
|
||||
};
|
||||
|
||||
memory.map(clear);
|
||||
|
||||
+13
-13
@@ -99,7 +99,7 @@ pub unsafe fn switch() -> bool {
|
||||
let mut context = context_lock.write();
|
||||
if runnable(&mut context, cpu_id) {
|
||||
to_ptr = context.deref_mut() as *mut Context;
|
||||
if (&mut *to_ptr).ksig.is_none() {
|
||||
if (*to_ptr).ksig.is_none() {
|
||||
to_sig = context.pending.pop_front();
|
||||
}
|
||||
break;
|
||||
@@ -113,7 +113,7 @@ pub unsafe fn switch() -> bool {
|
||||
let mut context = context_lock.write();
|
||||
if runnable(&mut context, cpu_id) {
|
||||
to_ptr = context.deref_mut() as *mut Context;
|
||||
if (&mut *to_ptr).ksig.is_none() {
|
||||
if (*to_ptr).ksig.is_none() {
|
||||
to_sig = context.pending.pop_front();
|
||||
}
|
||||
break;
|
||||
@@ -125,13 +125,13 @@ pub unsafe fn switch() -> bool {
|
||||
|
||||
// Switch process states, TSS stack pointer, and store new context ID
|
||||
if to_ptr as usize != 0 {
|
||||
(&mut *from_ptr).running = false;
|
||||
(&mut *to_ptr).running = true;
|
||||
(*from_ptr).running = false;
|
||||
(*to_ptr).running = true;
|
||||
if let Some(ref stack) = (*to_ptr).kstack {
|
||||
gdt::set_tss_stack(stack.as_ptr() as usize + stack.len());
|
||||
}
|
||||
gdt::set_tcb((&mut *to_ptr).id.into());
|
||||
CONTEXT_ID.store((&mut *to_ptr).id, Ordering::SeqCst);
|
||||
gdt::set_tcb((*to_ptr).id.into());
|
||||
CONTEXT_ID.store((*to_ptr).id, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
// Unset global lock before switch, as arch is only usable by the current CPU at this time
|
||||
@@ -146,16 +146,16 @@ pub unsafe fn switch() -> bool {
|
||||
// Signal was found, run signal handler
|
||||
|
||||
//TODO: Allow nested signals
|
||||
assert!((&mut *to_ptr).ksig.is_none());
|
||||
assert!((*to_ptr).ksig.is_none());
|
||||
|
||||
let arch = (&mut *to_ptr).arch.clone();
|
||||
let kfx = (&mut *to_ptr).kfx.clone();
|
||||
let kstack = (&mut *to_ptr).kstack.clone();
|
||||
(&mut *to_ptr).ksig = Some((arch, kfx, kstack, sig));
|
||||
(&mut *to_ptr).arch.signal_stack(signal_handler, sig);
|
||||
let arch = (*to_ptr).arch.clone();
|
||||
let kfx = (*to_ptr).kfx.clone();
|
||||
let kstack = (*to_ptr).kstack.clone();
|
||||
(*to_ptr).ksig = Some((arch, kfx, kstack, sig));
|
||||
(*to_ptr).arch.signal_stack(signal_handler, sig);
|
||||
}
|
||||
|
||||
(&mut *from_ptr).arch.switch_to(&mut (&mut *to_ptr).arch);
|
||||
(*from_ptr).arch.switch_to(&mut (*to_ptr).arch);
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ fn registry() -> MutexGuard<'static, Registry> {
|
||||
pub fn register(scheme_id: SchemeId, event_id: usize, clock: usize, time: TimeSpec) {
|
||||
let mut registry = registry();
|
||||
registry.push_back(Timeout {
|
||||
scheme_id: scheme_id,
|
||||
event_id: event_id,
|
||||
clock: clock,
|
||||
scheme_id,
|
||||
event_id,
|
||||
clock,
|
||||
time: (time.tv_sec as u64, time.tv_nsec as u64)
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user