Fixed clippy warnings

This commit is contained in:
Ryan Kennedy 2020-03-12 12:55:27 -05:00
parent 94b8cac780
commit c69c81a502
4 changed files with 17 additions and 19 deletions

View file

@ -7,7 +7,7 @@ use spinning_top::SpinlockGuard;
const WIDTH: usize = 640;
const HEIGHT: usize = 480;
static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3];
static PLANES: &[Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2, Plane::Plane3];
/// A basic interface for interacting with vga graphics mode 640x480x16
///
@ -23,6 +23,7 @@ static PLANES: &'static [Plane] = &[Plane::Plane0, Plane::Plane1, Plane::Plane2,
/// graphics_mode.set_mode();
/// graphics_mode.clear_screen();
/// ```
#[derive(Default)]
pub struct Graphics640x480x16;
impl Graphics640x480x16 {
@ -47,7 +48,7 @@ impl Graphics640x480x16 {
assert!(x < WIDTH, "x >= {}", WIDTH);
assert!(y < HEIGHT, "y >= {}", HEIGHT);
let (mut vga, frame_buffer) = self.get_frame_buffer();
let offset = (x / 8 + (WIDTH / 8) * y) as isize;
let offset = x / 8 + (WIDTH / 8) * y;
// Store the current value for masking.
let x = x & 7;
@ -56,14 +57,14 @@ impl Graphics640x480x16 {
for plane in PLANES {
vga.set_plane(*plane);
let current_value = unsafe { frame_buffer.offset(offset).read_volatile() };
let current_value = unsafe { frame_buffer.add(offset).read_volatile() };
let new_value = if plane_mask & color as u8 != 0 {
current_value | mask
} else {
current_value & !mask
};
unsafe {
frame_buffer.offset(offset).write_volatile(new_value);
frame_buffer.add(offset).write_volatile(new_value);
}
plane_mask <<= 1;
}

View file

@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
/// text_mode.set_mode();
/// text_mode.clear_screen();
/// ```
#[derive(Default)]
pub struct Text40x25;
impl Text40x25 {
@ -43,9 +44,7 @@ impl Text40x25 {
let (_vga, frame_buffer) = self.get_frame_buffer();
for i in 0..SCREEN_SIZE {
unsafe {
frame_buffer
.offset(i as isize)
.write_volatile(BLANK_CHARACTER);
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
}
}
}
@ -57,10 +56,10 @@ impl Text40x25 {
assert!(x < WIDTH, "x >= {}", WIDTH);
assert!(y < HEIGHT, "y >= {}", HEIGHT);
let (_vga, frame_buffer) = self.get_frame_buffer();
let offset = (WIDTH * y + x) as isize;
let offset = WIDTH * y + x;
unsafe {
frame_buffer
.offset(offset)
.add(offset)
.write_volatile(ScreenCharacter { character, color });
}
}

View file

@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
/// text_mode.set_mode();
/// text_mode.clear_screen();
/// ```
#[derive(Default)]
pub struct Text40x50;
impl Text40x50 {
@ -43,9 +44,7 @@ impl Text40x50 {
let (_vga, frame_buffer) = self.get_frame_buffer();
for i in 0..SCREEN_SIZE {
unsafe {
frame_buffer
.offset(i as isize)
.write_volatile(BLANK_CHARACTER);
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
}
}
}
@ -57,10 +56,10 @@ impl Text40x50 {
assert!(x < WIDTH, "x >= {}", WIDTH);
assert!(y < HEIGHT, "y >= {}", HEIGHT);
let (_vga, frame_buffer) = self.get_frame_buffer();
let offset = (WIDTH * y + x) as isize;
let offset = WIDTH * y + x;
unsafe {
frame_buffer
.offset(offset)
.add(offset)
.write_volatile(ScreenCharacter { character, color });
}
}

View file

@ -28,6 +28,7 @@ static BLANK_CHARACTER: ScreenCharacter = ScreenCharacter {
/// text_mode.set_mode();
/// text_mode.clear_screen();
/// ```
#[derive(Default)]
pub struct Text80x25;
impl Text80x25 {
@ -43,9 +44,7 @@ impl Text80x25 {
let (_vga, frame_buffer) = self.get_frame_buffer();
for i in 0..SCREEN_SIZE {
unsafe {
frame_buffer
.offset(i as isize)
.write_volatile(BLANK_CHARACTER);
frame_buffer.add(i).write_volatile(BLANK_CHARACTER);
}
}
}
@ -57,10 +56,10 @@ impl Text80x25 {
assert!(x < WIDTH, "x >= {}", WIDTH);
assert!(y < HEIGHT, "y >= {}", HEIGHT);
let (_vga, frame_buffer) = self.get_frame_buffer();
let offset = (WIDTH * y + x) as isize;
let offset = WIDTH * y + x;
unsafe {
frame_buffer
.offset(offset)
.add(offset)
.write_volatile(ScreenCharacter { character, color });
}
}