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