From d99c18d0bed98ec560e539f29d441ba1a5967f3f Mon Sep 17 00:00:00 2001 From: Ruihan Li Date: Sun, 27 Jul 2025 23:56:24 +0800 Subject: [PATCH] Remove `VmWriter::fill` --- ostd/src/mm/io.rs | 30 ------------------------------ ostd/src/mm/test.rs | 15 --------------- 2 files changed, 45 deletions(-) diff --git a/ostd/src/mm/io.rs b/ostd/src/mm/io.rs index eee1a512c..f246af2ff 100644 --- a/ostd/src/mm/io.rs +++ b/ostd/src/mm/io.rs @@ -754,36 +754,6 @@ impl<'a> VmWriter<'a, Infallible> { Ok(()) } - /// Fills the available space by repeating `value`. - /// - /// Returns the number of values written. - /// - /// # Panics - /// - /// The size of the available space must be a multiple of the size of `value`. - /// Otherwise, the method would panic. - pub fn fill(&mut self, value: T) -> usize { - let cursor = self.cursor.cast::(); - assert!(cursor.is_aligned()); - - let avail = self.avail(); - assert!(avail % core::mem::size_of::() == 0); - let written_num = avail / core::mem::size_of::(); - - for i in 0..written_num { - let cursor_i = cursor.wrapping_add(i); - // SAFETY: `written_num` is calculated by the avail size and the size of the type `T`, - // so the `write` operation will only manipulate the memory managed by this writer. - // We've checked that the cursor is properly aligned with respect to the type `T`. All - // other safety requirements are the same as for `Self::write`. - unsafe { cursor_i.write_volatile(value) }; - } - - // The available space has been filled so this cursor can be moved to the end. - self.cursor = self.end; - written_num - } - /// Converts to a fallible writer. pub fn to_fallible(self) -> VmWriter<'a, Fallible> { // It is safe to construct a fallible reader since an infallible reader covers the diff --git a/ostd/src/mm/test.rs b/ostd/src/mm/test.rs index 2ff2905b2..081292b5f 100644 --- a/ostd/src/mm/test.rs +++ b/ostd/src/mm/test.rs @@ -118,21 +118,6 @@ mod io { writer_infallible.write_val(&val).unwrap(); } - /// Tests the `fill` method in Infallible mode. - #[ktest] - fn fill_infallible() { - let mut buffer = vec![0u8; 8]; - let mut writer_infallible = VmWriter::from(&mut buffer[..]); - - // Fill with 0xFF - let filled = writer_infallible.fill(0xFFu8); - assert_eq!(filled, 8); - // Ensure the cursor is at the end - assert_eq!(writer_infallible.avail(), 0); - - assert_eq!(buffer, vec![0xFF; 8]); - } - /// Tests the `skip` method for reading in Infallible mode. #[ktest] fn skip_read_infallible() {