Skip to content

Commit

Permalink
fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tsemo4917 committed Sep 19, 2023
1 parent a5136d6 commit 2d7786e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<const ORDER: usize> FrameAllocator<ORDER> {
}
}

let result = self.free_list[class].iter().next().clone();
let result = self.free_list[class].iter().next();
if let Some(result_ref) = result {
let result = *result_ref;
self.free_list[class].remove(&result);
Expand Down Expand Up @@ -155,7 +155,7 @@ impl<const ORDER: usize> FrameAllocator<ORDER> {
let mut current_class = class;
while current_class < self.free_list.len() {
let buddy = current_ptr ^ (1 << current_class);
if self.free_list[current_class].remove(&buddy) == true {
if self.free_list[current_class].remove(&buddy) {
// Free buddy found
current_ptr = min(current_ptr, buddy);
current_class += 1;
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ extern crate spin;

extern crate alloc;

use core::alloc::{GlobalAlloc, Layout};
#[cfg(feature = "use_spin")]
use core::alloc::GlobalAlloc;
use core::alloc::Layout;
use core::cmp::{max, min};
use core::fmt;
use core::mem::size_of;
Expand Down Expand Up @@ -76,7 +78,7 @@ impl<const ORDER: usize> Heap<ORDER> {
pub unsafe fn add_to_heap(&mut self, mut start: usize, mut end: usize) {
// avoid unaligned access on some platforms
start = (start + size_of::<usize>() - 1) & (!size_of::<usize>() + 1);
end = end & (!size_of::<usize>() + 1);
end &= !size_of::<usize>() + 1;
assert!(start <= end);

let mut total = 0;
Expand Down Expand Up @@ -338,5 +340,5 @@ unsafe impl<const ORDER: usize> GlobalAlloc for LockedHeapWithRescue<ORDER> {
}

pub(crate) fn prev_power_of_two(num: usize) -> usize {
1 << (8 * (size_of::<usize>()) - num.leading_zeros() as usize - 1)
1 << (usize::BITS as usize - num.leading_zeros() as usize - 1)
}

0 comments on commit 2d7786e

Please sign in to comment.