Commit 1b9cd969 authored by Jeehoon Kang's avatar Jeehoon Kang Committed by Stefan Lankes
Browse files

Clippy

parent f4206943
...@@ -92,14 +92,12 @@ pub fn disable() { ...@@ -92,14 +92,12 @@ pub fn disable() {
#[cfg(not(test))] #[cfg(not(test))]
#[inline] #[inline]
pub fn nested_disable() -> bool { pub fn nested_disable() -> bool {
let result = unsafe { unsafe {
let flags: u64; let flags: u64;
llvm_asm!("pushfq; popq $0; cli" : "=r"(flags) :: "memory" : "volatile"); llvm_asm!("pushfq; popq $0; cli" : "=r"(flags) :: "memory" : "volatile");
rflags::RFlags::from_bits_truncate(flags).contains(rflags::RFlags::FLAGS_IF) rflags::RFlags::from_bits_truncate(flags).contains(rflags::RFlags::FLAGS_IF)
}; }
result
} }
#[cfg(test)] #[cfg(test)]
...@@ -503,6 +501,6 @@ impl IrqStatistics { ...@@ -503,6 +501,6 @@ impl IrqStatistics {
} }
pub fn inc(&mut self, pos: usize) { pub fn inc(&mut self, pos: usize) {
self.counters[pos] = self.counters[pos] + 1; self.counters[pos] += 1;
} }
} }
...@@ -298,8 +298,8 @@ impl CpuFrequency { ...@@ -298,8 +298,8 @@ impl CpuFrequency {
.expect("CPUID Brand String not available!"); .expect("CPUID Brand String not available!");
let ghz_find = brand_string.find("GHz"); let ghz_find = brand_string.find("GHz");
if ghz_find.is_some() { if let Some(ghz_find) = ghz_find {
let index = ghz_find.unwrap() - 4; let index = ghz_find - 4;
let thousand_char = brand_string.chars().nth(index).unwrap(); let thousand_char = brand_string.chars().nth(index).unwrap();
let decimal_char = brand_string.chars().nth(index + 1).unwrap(); let decimal_char = brand_string.chars().nth(index + 1).unwrap();
let hundred_char = brand_string.chars().nth(index + 2).unwrap(); let hundred_char = brand_string.chars().nth(index + 2).unwrap();
......
...@@ -17,7 +17,7 @@ pub struct Console; ...@@ -17,7 +17,7 @@ pub struct Console;
impl fmt::Write for Console { impl fmt::Write for Console {
/// Print a string of characters. /// Print a string of characters.
fn write_str(&mut self, s: &str) -> fmt::Result { fn write_str(&mut self, s: &str) -> fmt::Result {
if s.len() > 0 { if !s.is_empty() {
let buf = s.as_bytes(); let buf = s.as_bytes();
arch::output_message_buf(buf); arch::output_message_buf(buf);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#![allow(clippy::redundant_field_names)] #![allow(clippy::redundant_field_names)]
#![allow(clippy::identity_op)] #![allow(clippy::identity_op)]
#![allow(clippy::needless_range_loop)] #![allow(clippy::needless_range_loop)]
#![allow(clippy::tabs_in_doc_comments)]
#![allow(clippy::toplevel_ref_arg)] #![allow(clippy::toplevel_ref_arg)]
#![allow(clippy::not_unsafe_ptr_arg_deref)] #![allow(clippy::not_unsafe_ptr_arg_deref)]
#![allow(clippy::println_empty_string)] #![allow(clippy::println_empty_string)]
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
use crate::collections::{DoublyLinkedList, Node}; use crate::collections::{DoublyLinkedList, Node};
use alloc::rc::Rc; use alloc::rc::Rc;
use core::cell::RefCell; use core::cell::RefCell;
use core::cmp::Ordering;
pub struct FreeListEntry { pub struct FreeListEntry {
pub start: usize, pub start: usize,
...@@ -48,16 +49,20 @@ impl FreeList { ...@@ -48,16 +49,20 @@ impl FreeList {
) )
}; };
if region_size > size { match region_size.cmp(&size) {
// We have found a region that is larger than the requested size. Ordering::Greater => {
// Return the address to the beginning of that region and shrink the region by that size. // We have found a region that is larger than the requested size.
node.borrow_mut().value.start += size; // Return the address to the beginning of that region and shrink the region by that size.
return Ok(region_start); node.borrow_mut().value.start += size;
} else if region_size == size { return Ok(region_start);
// We have found a region that has exactly the requested size. }
// Return the address to the beginning of that region and move the node into the pool for deletion or reuse. Ordering::Equal => {
self.list.remove(node); // We have found a region that has exactly the requested size.
return Ok(region_start); // Return the address to the beginning of that region and move the node into the pool for deletion or reuse.
self.list.remove(node);
return Ok(region_start);
}
Ordering::Less => {}
} }
} }
......
...@@ -11,6 +11,7 @@ use alloc::boxed::Box; ...@@ -11,6 +11,7 @@ use alloc::boxed::Box;
use alloc::collections::BTreeMap; use alloc::collections::BTreeMap;
use alloc::string::String; use alloc::string::String;
use alloc::vec::Vec; use alloc::vec::Vec;
use core::ops::Deref;
/* /*
Design: Design:
...@@ -96,7 +97,7 @@ impl Filesystem { ...@@ -96,7 +97,7 @@ impl Filesystem {
fn parse_path<'a, 'b>( fn parse_path<'a, 'b>(
&'a self, &'a self,
path: &'b str, path: &'b str,
) -> Result<(&'a Box<dyn PosixFileSystem>, &'b str), FileError> { ) -> Result<(&'a dyn PosixFileSystem, &'b str), FileError> {
// assert start with / (no pwd relative!), split path at /, look first element. Determine backing fs. If non existent, -ENOENT // assert start with / (no pwd relative!), split path at /, look first element. Determine backing fs. If non existent, -ENOENT
if !path.starts_with('/') { if !path.starts_with('/') {
warn!("Relative paths not allowed!"); warn!("Relative paths not allowed!");
...@@ -108,7 +109,7 @@ impl Filesystem { ...@@ -108,7 +109,7 @@ impl Filesystem {
let internal_path = pathsplit.next().unwrap(); //TODO: this can fail from userspace, eg when passing "/test" let internal_path = pathsplit.next().unwrap(); //TODO: this can fail from userspace, eg when passing "/test"
if let Some(fs) = self.mounts.get(mount) { if let Some(fs) = self.mounts.get(mount) {
Ok((fs, internal_path)) Ok((fs.deref(), internal_path))
} else { } else {
info!( info!(
"Trying to open file on non-existing mount point '{}'!", "Trying to open file on non-existing mount point '{}'!",
......
use core::convert::TryInto;
use core::isize; use core::isize;
#[cfg(feature = "newlib")] #[cfg(feature = "newlib")]
use core::sync::atomic::AtomicUsize; use core::sync::atomic::AtomicUsize;
...@@ -239,14 +238,8 @@ fn __sys_spawn2( ...@@ -239,14 +238,8 @@ fn __sys_spawn2(
selector as u32 selector as u32
}; };
scheduler::PerCoreScheduler::spawn( scheduler::PerCoreScheduler::spawn(func, arg, Priority::from(prio), core_id, stack_size).into()
func, as Tid
arg,
Priority::from(prio),
core_id.try_into().unwrap(),
stack_size,
)
.into() as Tid
} }
#[no_mangle] #[no_mangle]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment