Fix various clippy warnings

pull/156/head
Andre Richter 2 years ago
parent 5d746828ad
commit 70f1ced57b
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -1797,7 +1797,7 @@ diff -uNr 11_exceptions_part1_groundwork/test-macros/src/lib.rs 12_integrated_te
+pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
+ let f = parse_macro_input!(input as ItemFn);
+
+ let test_name = &format!("{}", f.sig.ident.to_string());
+ let test_name = &format!("{}", f.sig.ident);
+ let test_ident = Ident::new(
+ &format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
+ Span::call_site(),

@ -11,7 +11,7 @@ use syn::{parse_macro_input, Ident, ItemFn};
pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
let test_name = &format!("{}", f.sig.ident.to_string());
let test_name = &format!("{}", f.sig.ident);
let test_ident = Ident::new(
&format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
Span::call_site(),

@ -11,7 +11,7 @@ use syn::{parse_macro_input, Ident, ItemFn};
pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
let test_name = &format!("{}", f.sig.ident.to_string());
let test_name = &format!("{}", f.sig.ident);
let test_ident = Ident::new(
&format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
Span::call_site(),

@ -2639,7 +2639,7 @@ diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory/mmu/translation_table.r
diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory/mmu/types.rs 14_virtual_mem_part2_mmio_remap/src/memory/mmu/types.rs
--- 13_exceptions_part2_peripheral_IRQs/src/memory/mmu/types.rs
+++ 14_virtual_mem_part2_mmio_remap/src/memory/mmu/types.rs
@@ -0,0 +1,375 @@
@@ -0,0 +1,373 @@
+// SPDX-License-Identifier: MIT OR Apache-2.0
+//
+// Copyright (c) 2020-2022 Andre Richter <andre.o.richter@gmail.com>
@ -3005,13 +3005,11 @@ diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory/mmu/types.rs 14_virtual
+ assert_eq!(allocation.num_pages(), 2);
+ assert_eq!(three_region.num_pages(), 1);
+
+ let mut count = 0;
+ for i in allocation.into_iter() {
+ for (i, alloc) in allocation.into_iter().enumerate() {
+ assert_eq!(
+ i.into_inner().as_usize(),
+ count * bsp::memory::mmu::KernelGranule::SIZE
+ alloc.into_inner().as_usize(),
+ i * bsp::memory::mmu::KernelGranule::SIZE
+ );
+ count = count + 1;
+ }
+ }
+}
@ -3588,7 +3586,7 @@ diff -uNr 13_exceptions_part2_peripheral_IRQs/src/memory.rs 14_virtual_mem_part2
+ bsp::memory::mmu::KernelGranule::SIZE * 2
+ );
+
+ assert_eq!(addr.is_page_aligned(), false);
+ assert!(!addr.is_page_aligned());
+
+ assert_eq!(addr.offset_into_page(), 100);
+ }

@ -160,7 +160,7 @@ mod tests {
bsp::memory::mmu::KernelGranule::SIZE * 2
);
assert_eq!(addr.is_page_aligned(), false);
assert!(!addr.is_page_aligned());
assert_eq!(addr.offset_into_page(), 100);
}

@ -363,13 +363,11 @@ mod tests {
assert_eq!(allocation.num_pages(), 2);
assert_eq!(three_region.num_pages(), 1);
let mut count = 0;
for i in allocation.into_iter() {
for (i, alloc) in allocation.into_iter().enumerate() {
assert_eq!(
i.into_inner().as_usize(),
count * bsp::memory::mmu::KernelGranule::SIZE
alloc.into_inner().as_usize(),
i * bsp::memory::mmu::KernelGranule::SIZE
);
count = count + 1;
}
}
}

@ -11,7 +11,7 @@ use syn::{parse_macro_input, Ident, ItemFn};
pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
let test_name = &format!("{}", f.sig.ident.to_string());
let test_name = &format!("{}", f.sig.ident);
let test_ident = Ident::new(
&format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
Span::call_site(),

@ -1146,11 +1146,15 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/console.rs 15_virt
pub unsafe fn panic_console_out() -> impl fmt::Write {
use driver::interface::DeviceDriver;
@@ -45,6 +46,23 @@
@@ -45,6 +46,27 @@
panic_uart
}
+/// Reduced version for test builds.
+///
+/// # Safety
+///
+/// - Use only for printing during a panic.
+#[cfg(feature = "test_build")]
+pub unsafe fn panic_console_out() -> impl fmt::Write {
+ use driver::interface::DeviceDriver;
@ -1170,7 +1174,7 @@ diff -uNr 14_virtual_mem_part2_mmio_remap/src/bsp/raspberrypi/console.rs 15_virt
/// Return a reference to the console.
pub fn console() -> &'static impl console::interface::All {
&super::PL011_UART
@@ -56,7 +74,15 @@
@@ -56,7 +78,15 @@
/// Minimal code needed to bring up the console in QEMU (for testing only). This is often less steps
/// than on real hardware due to QEMU's abstractions.

@ -47,6 +47,10 @@ pub unsafe fn panic_console_out() -> impl fmt::Write {
}
/// Reduced version for test builds.
///
/// # Safety
///
/// - Use only for printing during a panic.
#[cfg(feature = "test_build")]
pub unsafe fn panic_console_out() -> impl fmt::Write {
use driver::interface::DeviceDriver;

@ -160,7 +160,7 @@ mod tests {
bsp::memory::mmu::KernelGranule::SIZE * 2
);
assert_eq!(addr.is_page_aligned(), false);
assert!(!addr.is_page_aligned());
assert_eq!(addr.offset_into_page(), 100);
}

@ -363,13 +363,11 @@ mod tests {
assert_eq!(allocation.num_pages(), 2);
assert_eq!(three_region.num_pages(), 1);
let mut count = 0;
for i in allocation.into_iter() {
for (i, alloc) in allocation.into_iter().enumerate() {
assert_eq!(
i.into_inner().as_usize(),
count * bsp::memory::mmu::KernelGranule::SIZE
alloc.into_inner().as_usize(),
i * bsp::memory::mmu::KernelGranule::SIZE
);
count = count + 1;
}
}
}

@ -11,7 +11,7 @@ use syn::{parse_macro_input, Ident, ItemFn};
pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
let test_name = &format!("{}", f.sig.ident.to_string());
let test_name = &format!("{}", f.sig.ident);
let test_ident = Ident::new(
&format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
Span::call_site(),

@ -617,7 +617,7 @@ diff -uNr 15_virtual_mem_part3_precomputed_tables/src/bsp/raspberrypi/console.rs
.unwrap_or_else(|_| cpu::wait_forever());
panic_uart
@@ -51,13 +56,14 @@
@@ -55,13 +60,14 @@
pub unsafe fn panic_console_out() -> impl fmt::Write {
use driver::interface::DeviceDriver;
@ -880,7 +880,7 @@ diff -uNr 15_virtual_mem_part3_precomputed_tables/tests/02_exception_sync_page_f
- info!("Writing beyond mapped area to address 9 GiB...");
- let big_addr: u64 = 9 * 1024 * 1024 * 1024;
+ info!("Writing to bottom of address space to address 1 GiB...");
+ let big_addr: u64 = 1 * 1024 * 1024 * 1024;
+ let big_addr: u64 = 1024 * 1024 * 1024;
core::ptr::read_volatile(big_addr as *mut u64);
// If execution reaches here, the memory access above did not cause a page fault exception.

@ -52,6 +52,10 @@ pub unsafe fn panic_console_out() -> impl fmt::Write {
}
/// Reduced version for test builds.
///
/// # Safety
///
/// - Use only for printing during a panic.
#[cfg(feature = "test_build")]
pub unsafe fn panic_console_out() -> impl fmt::Write {
use driver::interface::DeviceDriver;

@ -160,7 +160,7 @@ mod tests {
bsp::memory::mmu::KernelGranule::SIZE * 2
);
assert_eq!(addr.is_page_aligned(), false);
assert!(!addr.is_page_aligned());
assert_eq!(addr.offset_into_page(), 100);
}

@ -368,13 +368,11 @@ mod tests {
assert_eq!(allocation.num_pages(), 2);
assert_eq!(three_region.num_pages(), 1);
let mut count = 0;
for i in allocation.into_iter() {
for (i, alloc) in allocation.into_iter().enumerate() {
assert_eq!(
i.into_inner().as_usize(),
count * bsp::memory::mmu::KernelGranule::SIZE
alloc.into_inner().as_usize(),
i * bsp::memory::mmu::KernelGranule::SIZE
);
count = count + 1;
}
}
}

@ -11,7 +11,7 @@ use syn::{parse_macro_input, Ident, ItemFn};
pub fn kernel_test(_attr: TokenStream, input: TokenStream) -> TokenStream {
let f = parse_macro_input!(input as ItemFn);
let test_name = &format!("{}", f.sig.ident.to_string());
let test_name = &format!("{}", f.sig.ident);
let test_ident = Ident::new(
&format!("{}_TEST_CONTAINER", f.sig.ident.to_string().to_uppercase()),
Span::call_site(),

@ -29,7 +29,7 @@ unsafe fn kernel_init() -> ! {
println!("Testing synchronous exception handling by causing a page fault");
info!("Writing to bottom of address space to address 1 GiB...");
let big_addr: u64 = 1 * 1024 * 1024 * 1024;
let big_addr: u64 = 1024 * 1024 * 1024;
core::ptr::read_volatile(big_addr as *mut u64);
// If execution reaches here, the memory access above did not cause a page fault exception.

Loading…
Cancel
Save